필터 지우기
필터 지우기

how to convert time unit in graphic

조회 수: 1 (최근 30일)
Kesni savitri
Kesni savitri 2013년 5월 20일
i have a trouble to make my task,
i use gui matlab to show a graph.
the graph i build from the calculated differential equation use ode45 with step size 1 hour.
there is 1 until 2160 hour. and i want to show the graph time unit in 'days' without change the step size of my ode45, so how can i do?

채택된 답변

Walter Roberson
Walter Roberson 2013년 5월 20일
For example,
plot(t(:,1), y(:,1))
curtick = get(gca, 'xtick');
newlab = cellstr( num2str( curtick(:) ./ 24 ) );
set(gca, 'xticklabel', newlab)
  댓글 수: 2
Kesni savitri
Kesni savitri 2013년 5월 20일
thanks for you answer, but i have 8 differensial equation, so i write...
plot(t(:,1), y(:,1),y(:,2),y(:,3),y(:,4),y(:,5),y(:,6),y(:,7),y(:,8))
curtick = get(gca, 'xtick');
newlab = cellstr( num2str( curtick(:) ./ 24 ) );
set(gca, 'xticklabel', newlab)
and was error to show the graph.
??? Error using ==> plot
Data must be a single matrix Y or a list of pairs X,Y
Error in ==> ruunmodel at 5
plot(t(:,1), y(:,1),y(:,2),y(:,3),y(:,4),y(:,5),y(:,6),y(:,7),y(:,8))
??? Error using ==> plot
Data must be a single matrix Y or a list of pairs X,Y
Error in ==> ruunmodel at 5
plot(t(:,1), y(:,1),y(:,2),y(:,3),y(:,4),y(:,5),y(:,6),y(:,7),y(:,8))
Walter Roberson
Walter Roberson 2013년 5월 20일
plot(t(:,1), y)
When you specify multiple numeric vector arguments for plot() you need to use the pattern x1 y1 x2 y2 x3 y3 ... Alternately you can use a common x, and specify the y as a matrix where the columns of y form the different lines. Your y(:,1), y(:,2) etc. are already columns in the "y" matrix, so you can give it as a single argument to draw all 8 of the columns.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by