Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

Date(class:cell) type problem

1 visualizzazione (ultimi 30 giorni)
Az
Az il 17 Giu 2011
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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!

Risposte (2)

Andrei Bobrov
Andrei Bobrov il 17 Giu 2011
cellfun(@(c)datestr(c,'yyyymmdd'),cellarraydate,'un',0)
  2 Commenti
Az
Az il 17 Giu 2011
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 il 17 Giu 2011
of course

Anthony Smith
Anthony Smith il 17 Giu 2011
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 Commento
Az
Az il 17 Giu 2011
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?

Questa domanda è chiusa.

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by