MATLAB Answers

Issue with plotting multiple data points on same graph

3 views (last 30 days)
Oscar Vobr
Oscar Vobr on 3 Jun 2020
Answered: Geoff Hayes on 3 Jun 2020
Hi, I am having trouble plotting data points on the same graph. Seperately they are function fine, but when graphed together, one set of data points does not change on the y-axis. Included is all related code to the issue. The issue is with the plot (t,a), the a part staying on zero on the y axis when graphed together with a_d
v0 = 50;
theta = 25;
N = 250; %number of time steps
a = zeros(1,N);
a(1) = -9.8;
a(2) = -9.8;
Tmax = 2*v0*sind(theta)/g;
t = linspace(0,2.5*Tmax,N); %seconds: Time axis
for n = 3:N
a(n) = -9.8;
end
figure (4)
plot(t,a_d,'r')
hold on
plot(t,a)
title('Magnitude of Acceleration with drag and no drag plotted against time')
hold off

  0 Comments

Sign in to comment.

Answers (1)

Geoff Hayes
Geoff Hayes on 3 Jun 2020
Oscar - look closely at the y-axis for the first image (that which plots both elements). There seems to be a factor of 10^4 so the ticks that we see are not 0, -5, -10, and -15 but 0, -5 x 10^4, -10 x 10^4, and -15 x 10^4. Since the blue line is at y=-9.8, then it makes sense that it is drawn at (or very close) to zero. You should probably confirm whether the -9.8 is correct and/or the calculation of the a_d elements (perhaps they are too large?).

  0 Comments

Sign in to comment.

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!