Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to plot weird timestamp in Matlab

I have a rather simple task. I just simply need to do something like that

plot(stampy{1:5},data{2}(1:5))

However, with stampy{1:5} I have five separate ans and data{2}(1:5) seems to be alright for plotting. i have tried to loop smth like that

cc=zeros(1,10);
for i=1:10
     cc(i) = stampy{i}
end

But it did not work. I don't know, it seems to be a very simple task. Can anybody suggest the solution ? I have data in this form:

>> stampy{1:5}
ans =
21-Sep-2016 05:52:00
ans =
21-Sep-2016 05:53:00  
ans =
21-Sep-2016 05:54:00
ans =
21-Sep-2016 05:55:00
ans =
21-Sep-2016 05:56:00

and

>> data{2}(1:5)

ans =

  -32.3750
  -25.0000
  -25.0000
  -25.0000
  -25.0000
like image 243
user2156115 Avatar asked Mar 10 '23 06:03

user2156115


1 Answers

You can use datenum to convert each of your dates to a date number and use this as the x axis. You can then use datetick to specify the format to use for your tick marks. This has the benefits that it works on most any version of MATLAB and it handles non-uniformly spaced dates.

plot(datenum(stampy), data{2}(1:5))
datetick('x', 'HH:MM:SS')

enter image description here

like image 163
Suever Avatar answered Mar 13 '23 13:03

Suever