How to build a weird timestamp in matlab

I have a pretty simple task. I just need to do something like this

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

However, with the stamp {1: 5} I have five separate ans and data {2} (1: 5) , it seems to be in order to build. I tried smth loop like this

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

But that did not work. I do not know, this is a very simple task. Can anyone suggest a 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
+4
source share
3 answers

datenum, x. datetick, , . , MATLAB .

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

enter image description here

+3

, datetime:

% the following line converts stampy to a time vector:
sy = datetime(stampy,'InputFormat','dd-MMM-yyyy HH:mm:ss');
plot(sy,data{2}(1:5))
+2

Just write down your data and rename Xticks as follows:

plot(data{2}(1:5));
set(gca,'XTick',1:5,'XTickLabel',{stampy{1:5}});

Conclusion:

output

+2
source

Source: https://habr.com/ru/post/1665853/


All Articles