Matlab time cell with 1 second interval

1 Ansicht (letzte 30 Tage)
buer
buer am 31 Mär. 2015
Kommentiert: Andrei Bobrov am 31 Mär. 2015
Hi,
I have one problem with date cell, I want the date in 1 second interval:
start_date=06-Jul-2011 15:20:00
end_date=06-August-2011 15:25:00 interval = 1/60/24/60; % 1 second date = datestr(start_date:interval:end_date);
However it is too slow... I think it maybe easy if just by filling in all time with 1 second interval... Is there any other way?
Thanks a lot.

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 31 Mär. 2015
Bearbeitet: Andrei Bobrov am 31 Mär. 2015
start_date='06-Jul-2011 15:20:00'
end_date='06-Aug-2011 15:25:00'
n = datenum({start_date;end_date},'dd-mmm-yyyy HH:MM:SS');
k = floor(diff(n)/(1/24/3600));
n1 = num2cell(datevec(n(1)));
s = datenum(n1{1:5},(0:k)');
out = datestr(s,'dd-mmm-yyyy HH:MM:SS');
  2 Kommentare
buer
buer am 31 Mär. 2015
Bearbeitet: buer am 31 Mär. 2015
Thanks for the reply....this works, but it looks like no faster way to do it...long time wait ...is it possible to work on '06-Jul-2011 15:20:00' kind of format diretly without converting to datenum....
Andrei Bobrov
Andrei Bobrov am 31 Mär. 2015
Use
out = datevec(s); % instead of 'out = datestr(s,'dd-mmm-yyyy HH:MM:SS');'

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by