フィルターのクリア

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 Center および File ExchangeLine Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by