Hello all I am trying to plot data from the attached test.mat file. If I just plot the data alone using the command plot(raw_summer_0mean), I got a nice curve shown below, but when I plot it with the time(attached below) , the curve is distorted. Any suggestions. Thanks in advance.
raw_summer_0mean=raw_summer-mean(raw_summer);
figure;plot(x_data_summer,raw_summer_0mean)
line([1 length(raw_summer_0mean)],[std(raw_summer_0mean) std(raw_summer_0mean)],'Color','r','LineWidth',1,'LineStyle','--')
line([1 length(raw_summer_0mean)],-[std(raw_summer_0mean) std(raw_summer_0mean)],'Color','r','LineWidth',1,'LineStyle','--')
text(x_data_summer(3),std(raw_summer_0mean)+1,['\sigma ',num2str(std(raw_summer_0mean))])
xlabel('Time')
ylabel('Precipitation Raw')
axis([min(x_data_summer) max(x_data_summer) min(raw_summer_0mean) max(raw_summer_0mean) ])
set(gca,'XTick',x_data_summer(1):diff(x_data_summer):x_data_summer(length(x_data_summer)))
datetick('x','yyyymmm','keeplimits', 'keepticks')
rotateXlabels(gca,90)

댓글 수: 2

Star Strider
Star Strider 2014년 6월 2일
Suggestions to do what?
ahmed shaaban
ahmed shaaban 2014년 6월 2일
The two curves suppose to be identical, I need suggestions to have get the same curve when I put time on x axes.

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

 채택된 답변

Chad Greene
Chad Greene 2014년 6월 2일

1 개 추천

Your time vector x_data_summer is not evenly spaced. When you only plot the raw_summer_0mean data, Matlab is assuming the x axis is evenly spaced. But your date numbers skip the winters.

댓글 수: 5

Chad Greene
Chad Greene 2014년 6월 2일
You don't have data in the winter, so when you reference your raw_summer_0mean data to its corresponding dates, Matlab will connect the last summer measurement of one year to the first summer measurement of the next year with a straight line.
Chad Greene
Chad Greene 2014년 6월 2일
ahmed shaaban
ahmed shaaban 2014년 6월 2일
ya, that is right, the data is only for June, July, august, September. Is there is any way to just enforce matlab to plot only the selected months without making such connections.
You mean like this?
[y,m,d] = datevec(x_data_summer);
for k = y(1):y(end)
plot(x_data_summer(y==k),raw_summer_0mean(y==k),'b*-');
hold on;
end
datetick
ahmed shaaban
ahmed shaaban 2014년 6월 3일
Yes,I try that and it give me the following figure. is there a way that I can enforce the datetick to be only in summer (July for example). The datetick here vary between all months Thanks alot
re. Thanks a lot.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2014년 6월 2일

댓글:

2014년 6월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by