Merry Christmas,
I wrote a battery analysis tool but I must say I never really cared about plotting, I work with numbers. What I get is a 8760x1 vector (8760 hours for every year ofc).
Now, thats the plot I get, unfortunately I can't manage to get 12 intervals on the xaxis, one for every month. I'd furthermore need to point out the plot max, in this case 6,1 TWh of necessary storage capacity.
Behold my paint skillz.
Thanks a lot
Daniel

回答 (1 件)

Steven Lord
Steven Lord 2020 年 12 月 20 日

0 投票

If you have date and time data stored as a datetime array just call plot.
x = datetime(2020, 1:12, 1);
y = (1:12).^2;
h = plot(x, y);
If you want to customize the appearance of the axes you could use xticks or xticklabels or for more extensive customization you can use its handle, which is easy to obtain from the handle returned by plot.
xticks(x(1:2:end))
ax = ancestor(h, 'axes');
ax.Color = 'r';

2 件のコメント

Daniel Bleich
Daniel Bleich 2020 年 12 月 20 日
Thanks but doesn't work unfortunately as my plotvector has 8760 entries.
So what I need is a command that splits those 8760 index numbers (1 to 8760) into 12 equal parts (730) on the x-axis and calls the first 730 January, next February and so on.
Steven Lord
Steven Lord 2020 年 12 月 21 日
What do those indices represent? February is not the same length as January so shouldn't they be represented by different length parts of the vector?

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeChristmas / Winter についてさらに検索

質問済み:

2020 年 12 月 20 日

コメント済み:

2020 年 12 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by