the conversion from data string to serial number

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 件のコメント

Stephen23
Stephen23 2023 年 5 月 12 日
Warning to others: the OP keeps changing their question.
shamal
shamal 2023 年 5 月 12 日
sorry.. i changed the question because the previous one i solved it
shamal
shamal 2023 年 5 月 12 日
sorry but the notification that someone had answered me arrived late..in the meantime I had solved the problem

サインインしてコメントする。

 採用された回答

Stephen23
Stephen23 2023 年 5 月 12 日
編集済み: Stephen23 2023 年 5 月 12 日

0 投票

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:
C = compose('%02d/01/2008',(1:10).')
C = 10×1 cell array
{'01/01/2008'} {'02/01/2008'} {'03/01/2008'} {'04/01/2008'} {'05/01/2008'} {'06/01/2008'} {'07/01/2008'} {'08/01/2008'} {'09/01/2008'} {'10/01/2008'}
N = datenum(C,'dd/mm/yyyy')
N = 10×1
733408 733409 733410 733411 733412 733413 733414 733415 733416 733417
checking:
datestr(N)
ans = 10×11 char array
'01-Jan-2008' '02-Jan-2008' '03-Jan-2008' '04-Jan-2008' '05-Jan-2008' '06-Jan-2008' '07-Jan-2008' '08-Jan-2008' '09-Jan-2008' '10-Jan-2008'

2 件のコメント

shamal
shamal 2023 年 6 月 4 日
編集済み: shamal 2023 年 6 月 4 日
HI, i ak you a question:
if i want to use only date (not date and time) you always advise me to use the 'format' datetime ?
(I don't care to use the time but only the dates)
Stephen23
Stephen23 2023 年 6 月 5 日
"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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDates and Time についてさらに検索

質問済み:

2023 年 5 月 12 日

コメント済み:

2023 年 6 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by