How can we plot the same time history plot two times but the second time with a time delay of 2 sec?

 採用された回答

Torsten
Torsten 2025 年 10 月 26 日
移動済み: Torsten 2025 年 10 月 26 日
You mean
t = 0:0.1:20;
p = t.^2;
hold on
plot(t,p,'b')
plot(t+2,p,'r')
hold off
grid on
?

その他の回答 (1 件)

Eric Sofen
Eric Sofen 2025 年 11 月 3 日
Without seeing your current code, it's hard to give a detailed response, but assuming your data is in a timetable, the lag function can be used to shift the time vector by either n timesteps or a time interval dt. Then you can plot that result the same way you're plotting your original dataset.

1 件のコメント

lag inserts leading NaN and drops trailing entries. That is not what most people would mean by plotting something with a delay.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

製品

リリース

R2024a

質問済み:

2025 年 10 月 26 日

コメント済み:

2025 年 11 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by