Why is my plot not showing a line?
Show older comments
I am not seeing the line on my plot. I am trying to plot the distance traveled by a projectile when launched. Thank You.
if true
% code
Planet=menu('Chose a Planet','Mercury','Venus','Earth','Mars','Jupiter','Saturn','Uranus','Neptune','Pluto');
Gravities = [3.59 8.87 9.81 3.77 25.95 11.08 10.67 14.07 0.42];
g = Gravities(Planet);
V=input('Enter the Velocity=');
Angle=input('Enter the angle=');
timpact=((2*V).*sind(Angle))./g;
fprintf('Time to Impact= %0.2f\n',timpact);
maxheight=(V.^2).*sin(deg2rad(Angle)).^2./(2.*g);
fprintf('Maximum height= %0.2f\n',maxheight);
t=timpact;
x0=0;
y0=0;
xt=V.*cosd(Angle).*t+x0 ;
yt=-(1./2).*g.*t.^2+(V.*sind(Angle).*t)+y0;
fprintf('Distance= %0.2f\n', xt);
plot(timpact,maxheight,xt,yt);
end
Accepted Answer
More Answers (0)
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!