What is the alternative of xtickformat() in the R2015a version?

1 回表示 (過去 30 日間)
Mohamed Nedal
Mohamed Nedal 2017 年 6 月 5 日
コメント済み: Walter Roberson 2017 年 6 月 5 日
Hello,
I was trying this code on the version R2015a:
t = 0:seconds(30):minutes(3);
y = rand(1,7);
plot(t,y)
xtickformat('mm:ss')
But I got this error:
Undefined function or variable 'xtickformat'.
How do I solve it please?

採用された回答

Walter Roberson
Walter Roberson 2017 年 6 月 5 日
datetick('x', 'mm:ss');
Note that in that release (and earlier releases) each time you zoom or pan, you will need to re-execute the datetick() command in order to update the tick labels properly.
In sufficiently new versions, if datetime or duration objects are used as the x axes, then the axes labels will be automatically updated as you zoom or pan. However, that facility had not been implemented in R2015a.
  2 件のコメント
Mohamed Nedal
Mohamed Nedal 2017 年 6 月 5 日
Thank you very much. I have another question please.
I tried this code:
t = 0:minutes(0):hours(10);
y = [10; 60; 12; 53; 47; 81; 25; 49; 83; 21];
plot(t,y)
datetick('x', 'HH:MM');
And I got a blank figure like this:
Why this happened and how to generalize this code for any hours-minutes combination?
Walter Roberson
Walter Roberson 2017 年 6 月 5 日
You are incrementing by minutes(0)
You probably meant minutes(60) . However, 0:minutes(60):hours(10) would be 11 entries and you only have 10 entries in y.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by