Ellen
Ellen

Reputation: 41

Convert datenum back to date when plotting in Matlab

I'm doing a simple plot in Matlab of windspeed vs time. I converted time using the datenum function, and able to do this plot. However, is there a way to convert the datenum outputs back into a date format when plotting?

Upvotes: 4

Views: 3202

Answers (2)

EBH
EBH

Reputation: 10440

I'm not sure when it was added, but now you can use the datetime format in the plot command:

taken from MATLAB docs (have a look also here):

t = 0:seconds(30):minutes(3);
y = rand(1,7);
plot(t,y,'DurationTickFormat','mm:ss')

will generate (something like) this:

DateTime plot

Upvotes: 0

HebeleHododo
HebeleHododo

Reputation: 3640

You can use the datetick function. It will convert the serial date numbers to human readable date.

Upvotes: 1

Related Questions