Passing datenum a column vector?

Hi, I have a column vector of dates in yyyymmdd format e.g.
19961016
19961017
19961018
19961021
19961022
19961023
19961024
Is there a way to convert each entry into a serial date number and have a column vector of serial date numbers back?
thanks friz

 採用された回答

Paulo Silva
Paulo Silva 2011 年 5 月 7 日

0 投票

d=[19961016
19961017
19961018
19961021
19961022
19961023
19961024];
d=num2str(d)-0;
Y=str2num(char(d(:,1:4)));
M=str2num(char(d(:,5:6)));
D=str2num(char(d(:,7:8)));
sd=datenum(Y,M,D)

1 件のコメント

friz
friz 2011 年 5 月 7 日
Works well. Thanks!!

サインインしてコメントする。

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2011 年 5 月 7 日

0 投票

more
sd = datenum(num2str(d),'yyyymmdd')

カテゴリ

ヘルプ センター および File ExchangeDates and Time についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by