フィルターのクリア

Trouble plotting multiple graphs

1 回表示 (過去 30 日間)
Josie
Josie 2014 年 8 月 20 日
編集済み: Patrik Ek 2014 年 8 月 20 日
I trying to plot multiple graphs of mass vs drag. I know the equation is correct but the plot's shouldn't be coming out with negative drag. Is there something wrong with the code?
M=linspace(0,1,100);
g=10;
for A=0.1:0.1:0.9
s=(A-0.5)*M.*g-(A^2)/4;
theta=s./(2*M.*(A-0.5)^2+2*M+(A^2-A+1/3)/2);
D=(-A.^2+A-1/3).*theta-0.5*A.^2;
plot(M,D)
axis([0,1,-2,2])
hold all
end
legend('A=0.1','A=0.2','A=0.3','A=0.4','A=0.5','A=0.6','A=0.7','A=0.8','A=0.9')
  1 件のコメント
Patrik Ek
Patrik Ek 2014 年 8 月 20 日
編集済み: Patrik Ek 2014 年 8 月 20 日
The equation for D is quite simple assuming theta is an independent variable, which it of course not is, since it is calculated. Still it can be treated as such to calculate D(theta), since D does not rely on M except for the dependence in theta. You can look at equation D as a function of theta and find out how D varies with theta.
This can be done by creating a vector theta = -2*pi:0.01:2*pi and use it as input to D. By plotting
plot(theta,D);
you will then see how D depends on theta for different values of A. With the help of these graphs you can see if the result is reasonable.

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

回答 (2 件)

Adam
Adam 2014 年 8 月 20 日
Well, the plots are negative because the result data is.
(-A.^2+A-1/3).*theta
ranges from -0.3785 to 0.4050.
0.5*A.^2
is 0.4050. So when you subtract this from the above the highest value you get will be 0, everything else will be negative

Iain
Iain 2014 年 8 月 20 日
Theres something wrong with your sums.
By hand, calculate D, for A = 0.1 and M = 0 & 100. You ought to see that D is negative.

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by