Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Issue with plotting multiple data points on same graph

1 visualizzazione (ultimi 30 giorni)
Oscar Vobr
Oscar Vobr il 3 Giu 2020
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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

Risposte (1)

Geoff Hayes
Geoff Hayes il 3 Giu 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?).

Prodotti


Release

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by