Calculating an area under a curve

% 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!
Area Calculation Matlab.jpg

7 Kommentare

Torsten
Torsten am 13 Mär. 2019
What information about the curve so you have ? An equation ? Single data points ?
Rengin
Rengin am 13 Mär. 2019
I have the single data points. For each time slot (t=0,...1), I have a "u" value. It is a curve from a simulator. There is not a specific function behind it.
Torsten
Torsten am 13 Mär. 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
KSSV am 13 Mär. 2019
Also have a look on polyarea.
Rengin
Rengin am 13 Mär. 2019
I think it works perfectly. Thank you very much!
Rengin
Rengin am 13 Mär. 2019
Dear Torsten,
You answered my question regarding the area under the curve. You suggested me the apply the equations below:
idx = t>0.2 ;
tp = t(idx );
up = u(idx );
area = trapz(tp,up)
I wonder if the calculated area is limited by the bottom dashed line or it also includes beyond this dashed line. I don't want to include the area from origin on but from P(0.2,187).
Thanks in advance!
Torsten
Torsten am 13 Mär. 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

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 13 Mär. 2019

Kommentiert:

am 13 Mär. 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by