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

2 次查看(过去 30 天)
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

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by