MATLAB: Area Under Curve (or Between Curve) areaarea under curve How to find area under curve, I try trapz, not working. sample=data(:,2); w=data(:,3); z=13.2 plot(sample, w, sample, z); area(w,z) how to calculate area of shaded region? Best Answer I understand the time reference is in sample=data(:,2)the function to integrate is in w=data(:,3) correct?and the z=13.2 is some kind of squelch you want to remove while integrating? there is no need to plot 2 functions.The area you are looking for is trapz(sample,w)you have assigned z a scalar, but it should match the length of the data to integrate.The integration goes from around 15 to 250, so the reference vector is tref=[15:1:250]if you really want to remove those 13.2 (volts?) while integrating, this DC is actually13.2*ones(1,length(tref)) so if you want to use two trapz, then trapz(sample,w)-z*ones(1,length(tref))does it make sense?regardsJohn Related SolutionsMATLAB: How to integrate this set of matrix data points You just need one for loop as trapz operates also on matrices. This is the piece of code:A = rand(32);B = zeros(32);for c = 1:size(A,2) B(:,c) = trapz(1:c,A(:,1:c),2);endB MATLAB: Find area of the filled region of a graph trapz(x,y) Related QuestionHow to do integration
Best Answer