필터 지우기
필터 지우기

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