datetick gives me errors

5 ビュー (過去 30 日間)
Scott Naucler
Scott Naucler 2019 年 8 月 6 日
回答済み: Star Strider 2019 年 8 月 6 日
I have a lot of experience in data crunching, but I am fairly new to MatLab. I am able to currently plot data, but when I try to display the x-axis values in hours:minutes (or any time format for that matter), a get an error. I know I am missing something silly, but I have searched the help files without luck for the last hour. Here is my code, with error.
>> figure
>> hold
Current plot held
>> plot(x,M01_80T)
>> datetick('x',13)
Error using datevecmx
The datevecmx function only accepts double arrays.
Error in datevec (line 309)
[y,mo,d] = datevecmx(t);
Error in dateTickPicker (line 85)
[y,m,d] = datevec(x);
Error in datetick>bestscale (line 307)
[labels,format] = dateTickPicker(axh,[xmin,xmax],dateform,dateChoice,axVal);
Error in datetick (line 260)
ticks = bestscale(axh,ax,vmin,vmax,dateform,dateChoice);

回答 (2 件)

dpb
dpb 2019 年 8 月 6 日
You don't show definition of X, but datetick works only for axes drawn with datenum which is a double.
But, datenum is old and deprecated and datetick is klunky at best...use the new datetime class instead and plot() is already datetime aware so don't need datetick at all.

Star Strider
Star Strider 2019 年 8 月 6 日
From the datetick documentation:
‘The axis data values should be serial date numbers, as returned by the datenum function.’
See datenum for details.
Another option would be to use datetime arrays (R2014b and later).

カテゴリ

Help Center および File ExchangeTitle についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by