How do I plot both for loop graphs?
Afficher commentaires plus anciens
At the moment I am trying to create two graphs one containing the values (t,v) and the other (t,h), and both need to be displayed at the same axis. I sincerely do not know how to create the graph as using plot does not work. here is my program so far:
% Position and velocity of a ball % Objective: To find the relationship between velocity and position of ball as a function of time when being released at an initial height. % Variable Notation: % g= gravity % t= time % V0= initial velocity of the ball % h0= the hight of the tallest building in Puerto Rico in meters % V= velocity as a function of time % h= height as a function of time
clc;clear
v0=0; g=-9.81; h0=49;
t=0;
t1=0;
for x= 1:100
v=g*t+v0;
h=((1/2)*g*(t1^2))+v0*t1+h0; plot(t,v);
fprintf('%f %f %f \n',t,h);
t1=t1+1;
t=t+1;
if h<=0
break
end
end
I really need help with this!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur 2-D and 3-D Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!