how can I determine the areas surrounded by these two plots?

1 Ansicht (letzte 30 Tage)
Moj
Moj am 9 Dez. 2014
Kommentiert: Moj am 14 Dez. 2014
Dear community,
I want to determine the area surrounded by these two plots. Please see the figure for more details.
My code is:
k11 = 10.5e-12;
k33 = 13.8e-12;
x = 0:1e-2:3.5;
y = q*0.5*sin(2*x)./(k11*sin(x).^2+k33*cos(x).^2);
plot(x,y,'r')
hold on
x = [0,3e-5, 7e-5, 2e-4, 6e-4, 0.002, 0.006, 0.01, 0.02, 0.03, 0.05, 0.07,...
0.09, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9, 1, 1.2, 1.4, 1.5, 1.8,2,...
2.3, 2.5, 2.9, 3.5];
y = [1.1195e6, 1.1195e+06, 1.1195e+06, 1.1195e+06, 1.1195e+06, 1.1194e+06,...
1.1192e+06, 1.1190e+06, 1.1184e+06, 1.1177e+06, 1.1161e+06, 1.1141e+06,...
1.1118e+06, 1.1105e6, 1.0930e6, 1.0669e6, 1.0321e6, 9.8841e5, 9.3568e5,...
8.7378e5, 7.2245e5, 6.3343e5, 4.3140e5, 2.0443e5, 8.5286e4, -2.7264e5,...
-4.9342e5, -7.7039e5, -9.1105e5, -1.0832e6, -1.0820e6];
plot(x,y,'o-')
end
How can I deal with this?

Akzeptierte Antwort

Roger Stafford
Roger Stafford am 9 Dez. 2014
You need to determine the x-coordinates of the three crossing points of the two curves. For that purpose you can use 'fzero', taking advantage of the fact that the empirical curve segment portions will be straight lines, and you can easily see from the plot which segments they are. Having found these x-coordinates, you can then use 'trapz' to find the two quantities s1 and s2 by integrating over the appropriate range the differences between the curves at the points of the empirical curve. At the crossing points, these will be zero, of course. For more accuracy you could use 'interp1' to produce additional points to use in 'trapz'.
  3 Kommentare
Roger Stafford
Roger Stafford am 13 Dez. 2014
What is the problem you are facing in using 'trapz'? As far as I can see, your approach looks reasonably valid even if a little unnecessarily complicated, assuming that 'fzero' converged successfully to the correct three values for x1, x2, and x3. The fact that you computed the integral of y1 minus the integral of y2 in both cases means that one of the areas will be negative and the other positive, but I see no other fundamental difficulty. If you want both to be positive, just take their absolute values.
One not very serious item. You appeared to use the same 'theta_0' for interpolating both curves, which I assume is the 31-element vector which you showed in your earlier code, and yet you had a precise formula for one of the curves, namely the function
q*0.5*sin(2*x)./(k11*sin(x).^2+k33*cos(x).^2)
In spite of my earlier remark, you didn't really have to use interpolation on this latter curve. You could have used interpolation on the one curve and the precise formula on the other one in finding their crossing points and in performing the integration. In fact there is a precise value for the integral of this formula since we know the integral of sin(2*x), sin(x)^2 and cos(x)^2, so you wouldn't have had to use 'trapz' for it. However, this shouldn't adversely affect the answer very much. With millions of intervals in your 'theta_00', 'trapz' should be exceedingly accurate for the sine curve.
Moj
Moj am 14 Dez. 2014
Thanks in advance. I am deeply grateful to you.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by