필터 지우기
필터 지우기

How to change x-axis values from iteration to time?

조회 수: 3 (최근 30일)
Khan
Khan 2021년 4월 26일
댓글: Khan 2021년 4월 26일
Hello,
I have a simple problem. I have generated a matrix called "A" (2000 by 1970). The rows of the matrix are velocity vectors while the columns represents the iteration numbers. In other words, the row vectors values are changing with iteration. A simple plot is given in the picture.
let's plot row number 277 of the given matrix,
figure (1)
plot(1:1970, A(277,:))
Now I would like to plot the same row vectors against the time (time on x-axis). The intial time is zero, final time should be 1.970 with time interval 0.001.
Can someone recomend how can I do it. Thank you.

채택된 답변

Walter Roberson
Walter Roberson 2021년 4월 26일
dt = 0.001;
time = (0:size(A,2)-1) * dt;
plot(time, A(277,:));
Note that the final value will be 1.969 not 1.970 since your time starts at 0.
  댓글 수: 3
Walter Roberson
Walter Roberson 2021년 4월 26일
To get exactly 1.970 with dt 0.001 and starting from 0, you would need your A to have 1971 columns instead of 1970.
Khan
Khan 2021년 4월 26일
Ok, Thank you.

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by