T1 = readtable('testdata.xlsx'); x = T1.Displacement; y = T1.BaseForce; % top flat curve (apex) [m,idy] = max(y); ym = m*ones(size(y)); plot(x,y,'*-',x,ym,'g','Linewidth',3); hold on % red curve ( "yellow" net area must be zero) % origin = 0,0 (first data point) x1 = x(1); y1 = y(1); % let's find out which second point of the curve let us find the min area xx = x(1:idy); yy = y(1:idy); for ck = 2:idy x2 = x(ck); y2 = y(ck); slope = (y2-y1)/(x2-x1); yl = y1 + slope*(xx - x1); % compute yellow area A A(ck) = trapz(xx,(yy-yl)); end % find zero crossing value for A (with linear interpolation) threshold = 0; xx_zc = find_zc(xx,A,threshold); yy_zc = interp1(xx,yy,xx_zc); slope = (yy_zc-y1)/(xx_zc-x1); yl = y1 + slope*(xx - x1); plot(xx,yl,'r','Linewidth',3); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [Zx] = find_zc(x,y,threshold) % positive slope "zero" crossing detection, using linear interpolation y = y - threshold; zci = @(data) find(diff(sign(data))>0); %define function: returns indices of +ZCs ix=zci(y); %find indices of + zero crossings of x ZeroX = @(x0,y0,x1,y1) x0 - (y0.*(x0 - x1))./(y0 - y1); % Interpolated x value for Zero-Crossing Zx = ZeroX(x(ix),y(ix),x(ix+1),y(ix+1)); end
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.