Why do I get error 'incorrect argument data type' when using "datetick" function for plots with "duration" datatype?

I am plotting some values against "duration" datatype. When I try to use "datetick" function to change format of duration values, it throws me an error.
>> t = 0:seconds(30):minutes(3); >> y = rand(1,7); >> plot(t,y) >> datetick('x','mm:ss.FFF') Check for missing argument or incorrect argument data type in call to function 'log10'. Error in dateTickPicker (line 71) yearDelta = 10.^(max(0,round(log10(xmax-xmin)-3)))* ... 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);

 채택된 답변

Note that "datetick" is a legacy function introduced long ago. MATLAB documentation recommends using newer functions such as "datetime" and "xtickformat". "datetick" is useful when plotting numeric values that are serial date numbers. To view the specific documentation for "datetick" in MATLAB R2019b, execute the following command in the command window:
>> web(fullfile(docroot, 'matlab/ref/datetick.html'))
To resolve the issue, please use the "xtickformat" function.
>> plot(t,y); >> xtickformat('mm:ss.SSS');
To check which duration formats are supported, refer to the documentation page by executing the following command in the MATLAB R2019b command window:
>> web(fullfile(docroot, 'matlab/ref/duration.html'))
Please follow the link below to search for the required information regarding the current release:

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Dates and Time에 대해 자세히 알아보기

제품

릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by