the conversion from data string to serial number
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Luca Re
el 12 de Mayo de 2023
Comentada: Stephen23
el 5 de Jun. de 2023
I have to convert from string (cell) to serial number but it's slow..is there a faster method?
formatin='dd/mmm/yyyy';
for i = 1:length(TabStrum_Nome)
dataa(:,i)=datenum(A.textdata,formatin);
end
>> class(A.textdata)
ans =
'cell'
>>
3 comentarios
Respuesta aceptada
Stephen23
el 12 de Mayo de 2023
Editada: Stephen23
el 12 de Mayo de 2023
Yes, that is the wrong date.... it is also the wrong data type: why are you using deprecated serial date numbers?
The DATENUM documentation states at the top:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1381434/image.png)
C = compose('%02d/01/2008',(1:10).')
N = datenum(C,'dd/mm/yyyy')
checking:
datestr(N)
2 comentarios
Stephen23
el 5 de Jun. de 2023
"if i want to use only date (not date and time) you always advise me to use the 'format' datetime ?"
That depends entirely on what you mean by "use", which you have not explained.
Changing the DATETIME format changes how it displays/converts to text, but does not change the value of the DATETIME object itself. So if you want e.g. to compare DATETIME values or group them, it doesn't have any effect.
Más respuestas (0)
Ver también
Categorías
Más información sobre Time Series Objects en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!