File Exchange

image thumbnail

timetick - legacy

version 1.3.0.1 (2.91 KB) by Michelle Hirsch
Time formatted tick labels.

1 Download

Updated 04 Dec 2019

From GitHub

View Version History

View license on GitHub

This was sweet in its time, but has now been superseded by much nicer capabilities built into MATLAB: datetime (R2014b) and datetime ruler (R2016b). I strongly suggest you use them instead!

TIMETICK sets current axes to time formatted tick labels. X Axis must be time, in datenum format.

TIMETICK(AX) sets axes with handle AX to time formatted tick labels.

TIMETICK(AX,precision) sets axes with handle AX to time formatted tick labels with precision values to the right of the decimal for seconds specifier.
Use TIMETICK instead of DATETICK when you want fractional second precision. Unlike DATETICK, TIMETICK works well with ZOOM.

See also TIMESTR.

Cite As

Michelle Hirsch (2021). timetick - legacy (https://github.com/michellehirsch/timetick), GitHub. Retrieved .

Comments and Ratings (9)

Rob Newman

My bad - just found the datetick() function. Please ignore previous post...

Rob Newman

What about if you have a long time series (years) and want output in YYYY-MM-DD? This function only seems to be relevant for second/microsecond time periods????? Any ideas? Thanks.

Hithesh

To resolve the error mentioned in 2nd reply, just use timetick
without any input. Default is x axis.
(credit: Scott Hirsch)

Alex Fay

I aded some more edits, I can't seem to upload them, though.

Alex Fay

Alex Fay

And now in English.
fmt = ['%02d:%02d:%0' totalwidth '.' precision 'f'];

The leading zero also works on fixed-point. For example, if the seconds format is '%07.4f', a seconds value of 0.440 seconds comes out as '00.4400'.

Mike Russell

Implementation can be improved. I improved its capability to include all axis's. The timestr function seems a little involved since it is performing datestr for however many ticks you have chosen.

If anyone has come to a solution on how to update the tick labels after zoom let me know.

Thanks

rick zhang

It did not work for me in 7.0.1.24704 (R14) Service Pack 1 although timestr worked. I received the message below. Hope the author will fix it soon.

>> timetick('x', 'HH:MM:SS.SSSS')
??? Error using ==> get
Invalid handle.

Error in ==> timetick at 26
xt = get(ax,'XTick');

JARRAD YUNG-TAO CHOU

NOT USED YET

MATLAB Release Compatibility
Created with R2019b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!