필터 지우기
필터 지우기

Needed help with figures

조회 수: 1 (최근 30일)
Michela
Michela 2015년 10월 4일
편집: Stephen23 2015년 10월 4일
Hello to everybody, I'm not a real expert on Matlab use, but I need to be more confident with it because I have to write my master thesis by using this software. I have a problem with a figure: I have plot an historical data series that have a monthly frequency data, I would like that in axes x do not appear the number that Matlab gives to my dates, but the dates themselves (01-2000, or Jan-00, or something like this instead of 10, 20, ... ). I hope to have well explained my problem. Thank you!! Michela

채택된 답변

Stephen23
Stephen23 2015년 10월 4일
편집: Stephen23 2015년 10월 4일
You could use the datetick command, which has many date format options for you to choose from. Read the documentation carefully and pick the best one for your needs. Here is an example of how it can be used:
>> t = (1900:10:1990).';
>> p = [75,91,105,123,131,150,179,203,226,249].';
>> bar(datenum(t,1,1),p)
>> datetick('x',28)
Which creates this:
You can adjust the axes limits using the xlim function, and its equivalents ylim, etc.

추가 답변 (1개)

Michela
Michela 2015년 10월 4일
Thanks Stephen Cobeldick for your useful answer! I have tried and it works quite perfectly. Now the probelm is that does not appear the "real" year, but 0000. I can't understand why... Thanks again
  댓글 수: 1
Stephen23
Stephen23 2015년 10월 4일
편집: Stephen23 2015년 10월 4일
Note that the X-axis needs to be supplied with a serial date number, not just a values that is the year that you want. Have a look at my example and you can see that I use the function datenum to convert a vector of years (1900,1910,...) into serial date numbers, and these are the X-values that I plotted.

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by