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

조회 수: 13 (최근 30일)
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
Walter Roberson
Walter Roberson 2025년 11월 29일
lag inserts leading NaN and drops trailing entries. That is not what most people would mean by plotting something with a delay.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by