Calculating an area under a curve
Show older comments
% Dear users,
% Is there any way to calculate an area under a curve as in the figure?
% It would really appreciate if you can help me.
% Thanks in advance!

7 Comments
Torsten
on 13 Mar 2019
What information about the curve so you have ? An equation ? Single data points ?
Rengin
on 13 Mar 2019
Torsten
on 13 Mar 2019
If t and u are the arrays with the data points, you can use
idx = t>0.2;
tp = t(idx);
up = u(idx);
area = trapz(tp,up)
KSSV
on 13 Mar 2019
Also have a look on polyarea.
Rengin
on 13 Mar 2019
Rengin
on 13 Mar 2019
Torsten
on 13 Mar 2019
The formula is gives an approximation for
integral_{t=0.2}^{t=t(end)} u(t) dt.
It seems that you want the area start at u=0.2.
Then subtract the area of the rectangle between u=0 and u=0.2 for 0.2 <= t <= t(end), i.e.
area = trapz(tp,up) - (tp(end)-0.2)*0.2
Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!