Both function plots start at 1, even though I have time step as t=0:6

2 ビュー (過去 30 日間)
Ashleigh
Ashleigh 2024 年 9 月 1 日
コメント済み: Ashleigh 2024 年 9 月 1 日
I am working to plot two basic functions from 0 to 6. When the section is ran, the plots are correct except that it is starting from 1 and not 0.
a_2 = -16;
a_3 = 1/3;
t = 0:6;
v = a_2 + (3*a_3*(t.^2));
a = 6*a_3*t;
plot(v)
hold on
plot(a)
hold off
xlabel('Time (s)')
ylabel('Velocity (m/s), Acceleration (m/s^2)')
xlim([0,t(end)])
ylim([-17,24])

採用された回答

Torsten
Torsten 2024 年 9 月 1 日
Use
plot(t,v)
plot(t,a)
instead of
plot(v)
plot(a)

その他の回答 (1 件)

Sam Chak
Sam Chak 2024 年 9 月 1 日
a_2 = -16;
a_3 = 1/3;
t = 0:6;
v = a_2 + (3*a_3*(t.^2));
a = 6*a_3*t;
plot(t, v) % <-- plot(xvalues, yvalues)
hold on
plot(t, a)
hold off
xlabel('Time (s)')
ylabel('Velocity (m/s), Acceleration (m/s^2)')
xlim([0,t(end)])
ylim([-17,24])
grid on, grid minor

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by