Building Time Series Data in Matlab

I have data from 2007/5/1 to 2007/5/30 from 00:00 to 23:59:58. I want to build this data according to data and time together. How can I determine the date and time together? because he has the usual date and time. for instance

2007/5/1 00:00:00 -0.2 2007/5/1 00:00:02 -0.1 2007/5/1 00:00:04 -0.12 . . . 2007/5/31 23:59:58 -0.4 

I used DateTime code, but I have a regular time interval and I don’t know how to solve it.

+1
source share
1 answer

Here is an example using the datetime variable. You will need to import your data into the corresponding vector, which is aligned with the time vector ( t below), so data(i) is the corresponding data for t(i) .

 % create a datetime vector of all instances: start = datetime('2007/5/1 00:00:00','InputFormat','uuuu/MM/dd HH:mm:ss'); step = duration(seconds(2)); fin = datetime('2007/5/31 23:59:58','InputFormat','uuuu/MM/dd HH:mm:ss'); t = start:step:fin; % a 1339200 elements vector, of all time steps % some random data: data = rand(numel(t),1); % plotting samples 1 to 100: plot(t(1:100),data(1:100)) xlim([datenum(t(1)) datenum(t(100))]) 

I use random numbers here as an example, and you cannot see anything for such a long vector, so I draw only part of it:

plotDate

0
source

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


All Articles