MATLAB Answers

How to write datetime in a plot?

28 views (last 30 days)
Diego on 31 Jan 2014
Commented: Mischa Kim on 13 Feb 2014
I want to read a file.csv but my problem is that i don't know how can I represent in a plot the hour.
My goal is to represent a number as a datetime but I don't Know if it's possible to convert it as in the next example:
131212 --> HH:MM:SS --> 13:12:12
And then put this number in that format in an x-axis in a plot.


Sign in to comment.

Accepted Answer

Mischa Kim
Mischa Kim on 31 Jan 2014
Edited: Mischa Kim on 31 Jan 2014
This should do:
T0 = '131212';
T0Vec = [2000,0,0,str2double(T0(1:2)),str2double(T0(3:4)),str2double(T0(5:6))];
T0Str = datestr(T0Vec,'HH:MM:SS');
Once you have the string you can put it on the xlabel for your plot or add it as a text element.


Mischa Kim
Mischa Kim on 12 Feb 2014
Yes, that's the problem. There're just too many labels, if you print them all.
About your second question: I am not sure I understand. Do you want to print a label right next to each RSSI data point? If so, check out this answer. If no, please further elaborate.
By the way, my name is Mischa :)
Diego on 12 Feb 2014
Yes I wanna do this! I'll try to do it!
I apologize for the confusion, I want to say Mischa! I was writing so quickly...!
Mischa Kim
Mischa Kim on 13 Feb 2014
Hello Diego. Good to see you again. Would you mind opening another question? It is not really on the topic of your original question, which would make it challening to find for other users. Plus this thread is getting kind of long.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!