필터 지우기
필터 지우기

how to plot two graphs ?

조회 수: 1 (최근 30일)
Rita
Rita 2016년 3월 8일
댓글: Star Strider 2016년 3월 9일
I have two matrices to plot
A=[1 1.2
3 2.3
7 3.2
8 3 ]
and
B=[2 3.2
4 4.5
5 7
6 0 ]
I want to create a plot
plot(A(:,1),A(:,2),'r');
hold on
plot(B(:,1),B(:,2),'b');
but instead of x it should be month. Any suggestion would be appreciated in advance.

채택된 답변

Star Strider
Star Strider 2016년 3월 8일
편집: Star Strider 2016년 3월 8일
One approach that will use local month names:
A=[1 1.2
3 2.3
7 3.2
8 3 ]
B=[2 3.2
4 4.5
5 7
6 0 ]
dn = datenum([repmat(2016, size(A,1)+size(B,1), 1) [A(:,1); B(:,1)], ones(size(A,1)+size(B,1), 1)]); % Create Date Numbers From Months
plot(dn(1:size(A,1)) ,A(:,2),'r');
hold on
plot(dn(size(A,1)+1:end),B(:,2),'b');
datetick('x', 'mmm')
  댓글 수: 8
Rita
Rita 2016년 3월 9일
Thank you so much.It is exactly what I need.I really appreciate your great help.
Star Strider
Star Strider 2016년 3월 9일
As always, my pleasure!

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

추가 답변 (1개)

Chad Greene
Chad Greene 2016년 3월 8일
Is this what you want?
set(gca,'xtick',1:8,'xticklabel',{'jan','feb','mar','apr','may','jun','jul','aug'})

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by