How do I plot both for loop graphs?
显示 更早的评论
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!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 2-D and 3-D Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!