Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Date(class:cell) type problem

1 回表示 (過去 30 日間)
Az
Az 2011 年 6 月 17 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have cell array containing only dates(imported from excel) I want to change them into YYYYMMDD type. Datestr doesn't work and I tried cell2mat then datestr, but the result is quite wierd since many of the dates are missing from the result. I tried to export to excel to set the date type but some of them remain the same. So I am wondering how can I deal with this? driving me nuts. Thank you so much!

回答 (2 件)

Andrei Bobrov
Andrei Bobrov 2011 年 6 月 17 日
cellfun(@(c)datestr(c,'yyyymmdd'),cellarraydate,'un',0)
  2 件のコメント
Az
Az 2011 年 6 月 17 日
Dear andrei bobrov,
Thanks for your answer.
But it didn't work with my file.
Is there anyway I can Upload the file to you?
Andrei Bobrov
Andrei Bobrov 2011 年 6 月 17 日
of course

Anthony Smith
Anthony Smith 2011 年 6 月 17 日
datestr seems to only operate on strings so you probably need to access the contents of each cell individually rather than using an array operation. Using datestr format 29 for example:
for i=1:size(cellArray,1)
for j=1:size(cellArray,2)
newFormattedString = datestr(cellArray{i,j} ,29);
end
end
  1 件のコメント
Az
Az 2011 年 6 月 17 日
Dear Anthony Smith,
Thanks for your answer.
But it didn't work with my file.
Is there anyway I can Upload the file to you?

この質問は閉じられています。

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by