Trouble plotting multiple graphs
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Patrik Ek
il 20 Ago 2014
Modificato: Patrik Ek
il 20 Ago 2014
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.
Risposte (2)
Adam
il 20 Ago 2014
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
0 Commenti
Iain
il 20 Ago 2014
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.
0 Commenti
Vedere anche
Categorie
Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!