How do you plot a graph when using a while loop?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
When I run this code, I get a blank graph. How would I fix the code so that I would be able to see the actual graphed data?
V0=100;
G=9.8;
theta=pi/4;
T=-0.01;
while (T<=20)
T=T+0.01;
HT=T*V0*cos(theta);
end
plot(T,HT);
title('horizontal path');
xlabel('time(s)');
ylabel('distance(m)');
0 Commenti
Risposte (1)
David Hill
il 15 Apr 2020
V0=100;
G=9.8;
theta=pi/4;
T(1)=-0.01;
c=0;
while (T<=20)
c=c+1;
T(c+1)=T(c)+0.01;
HT(c)=T(c+1)*V0*cos(theta);
end
plot(T(2:end),HT);
title('horizontal path');
xlabel('time(s)');
ylabel('distance(m)');
Much easier without a loop.
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!