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개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!