Area Under Curve (or Between Curve)
2 views (last 30 days)
Show older comments

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?
2 Comments
Accepted Answer
John BG
on 9 Dec 2015
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 actually
13.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?
regards
John
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!