How do I convert a cell array of character strings into datetime array efficiently?
古いコメントを表示
I have a cell array of character strings which contains column headers and my time stamp information we will call txt. I want to be able to efficiently extract the timestamp column and convert it to seconds. counting up from zero at the first entry. I tried to use datenum as follows;
t=(datenum(txt{6:end,1})-datenum{6,1})*60^2*24
However, datenum returns a error claiming too many arguments. Next I tried to use cellfun to do the job;
t=(cellfun(@datenum,txt{6:end,1})-datenum(txt{6,1}))*60^2*24
However, this returns an error on cellfun saying input #2 was expected to be a cell array but was char instead. Surely there is a more elegant way than setting up a loop to march through and do it line by line...
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!