One of my plots won't show and when it should just be a straight horizontal line.

1 view (last 30 days)
Hello I'm having difficulty with having a show up in my first graph. Here is the code.
xi = 0:50; %initial position
a = -9.81; %acceleration
vi = 0; %initial speed
t = sqrt( -2*xi./a);
x = .5*a*(t.^2);
v = t.*a;
subplot(2,1,1)
plot (t , x, 'r')
xlim ([0,4])
xlabel ('time')
ylabel ('m/s - m/s^2')
hold on
plot (t , v, 'b')
hold on
plot (t, a, 'g')
hold on
legend ('x', 'v' , 'a')
subplot(2,1,2)
plot (x , v, 'b')
xlabel('altitude')
ylabel('velocity')
legend ('v')

Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!