How to plot the values from while loop? I got blank graph
Show older comments
theta=input('Enter the launch angle in degrees:');
TimeIncrement=input('Enter the time increment in seconds:');
g=9.81;
Ti=0;
Xi=0;
Yi=100;
Vi=50;
t=0;
x=cosd(theta)*Vi*t;
y=Yi+(g/2)*(t+TimeIncrement)^2;
Vxi=cosd(theta)*Vi;
Vyi=sind(theta)*Vi;
fprintf('Vx = %g m/s\n\n',Vxi)
fprintf('Vy = %g m/s\n\n',Vyi)
y=100+1/2*(-9.81)*t^2;
while y>0
t=t+TimeIncrement;
y=Yi+Vyi*t+(-9.8/2)*(t)^2;
x=t*Vxi;
Vxf=Vxi;
Vyf=Vyi+(-9.81)*t;
end
plot(x,y)
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!