Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Issue with plotting multiple data points on same graph

1 回表示 (過去 30 日間)
Oscar Vobr
Oscar Vobr 2020 年 6 月 3 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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

回答 (1 件)

Geoff Hayes
Geoff Hayes 2020 年 6 月 3 日
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?).

タグ

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by