Is my approach true to find the area by using 'trapz'?

1 回表示 (過去 30 日間)
Moj
Moj 2014 年 12 月 13 日
コメント済み: Roger Stafford 2014 年 12 月 13 日
Dear community,
I want to determine s1 and s2 areas which are surrounded by these two plots (please see the figure).
First, I interpolated these two plots:
theta_00 = 0:1e-6:3.5;
y1 = interp1(theta_0, dtheta,theta_00, 'spline');
y2 = interp1(theta_0, dtheta_2, theta_00, 'spline');
in the second place, I used 'fzero' to find the roots:
fun = @(x) interp1(theta_00, (y1 - y2) , x,'spline');
x1 = fzero(fun,[0 1]) % finding roots of fun which is interpolated.
x2 = fzero(fun,[1 2])
x3 = fzero(fun,[2 3])
and now I want to determine these s1 and s2 areas, my problem here. I used 'trapz' like this, but I do not know am I calculating the right values of s1 and s2 ?
theta_00 = x1:1e-6:x2;
y1 = interp1(theta_0, dtheta,theta_00, 'spline');
y2 = interp1(theta_0, dtheta_2, theta_00, 'spline');
area_1 = trapz(theta_00,y1)- trapz(theta_00,y2)
theta_00 = x2:1e-6:x3;
y1 = interp1(theta_0, dtheta,theta_00, 'spline');
y2 = interp1(theta_0, dtheta_2, theta_00, 'spline');
area_2 = trapz(theta_00,y1)- trapz(theta_00,y2)
By the way, I do not know am I calculating the right values of s1 and s2 in using 'trapz'.
Thanks in advance
  1 件のコメント
Roger Stafford
Roger Stafford 2014 年 12 月 13 日
See my remarks in Answers #166058.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by