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

16 vues (au cours des 30 derniers jours)
How can we plot the same time history plot two times but the second time with a time delay of 2 sec?

Réponse acceptée

Torsten
Torsten le 26 Oct 2025
Déplacé(e) : Torsten le 26 Oct 2025
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
?

Plus de réponses (1)

Eric Sofen
Eric Sofen le 3 Nov 2025 à 17:03
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 commentaire
Walter Roberson
Walter Roberson il y a environ 9 heures
lag inserts leading NaN and drops trailing entries. That is not what most people would mean by plotting something with a delay.

Connectez-vous pour commenter.

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by