convert DateString in cell array

2 次查看(过去 30 天)
Hello I have a cell array 3x2
A = [5] '09/16/2007'
[2] '05/14/1996'
[3] '11/29/2010'
I would like to convert the Date from String to a usable format I can do it with
datevec(DateString,formatOut)
but lastly Matlab doesnt accept the new double for my cell array can someone help pls :)

回答(1 个)

Star Strider
Star Strider 2016-10-20
This works for me:
A = {[5] '09/16/2007'
[2] '05/14/1996'
[3] '11/29/2010'};
dn = datenum(A(:,2), 'mm/dd/yyyy'); % Date Numbers
check = datevec(dn); % Check Conversion (Delete This Line Later)
You need to only use the second column of ‘A’ for the dates. The datenum function does not know what to do with the first column (and neither do I).

类别

Help CenterFile Exchange 中查找有关 Data Type Conversion 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by