convert Cell to double
显示 更早的评论
Hi,
I have C{1,1}<1500x1 cell> which contains data like:
'10/21/2013 13:11:34.0289993'
'10/21/2013 13:11:34.1289978'
'10/21/2013 13:11:34.2289962'
'10/21/2013 13:11:34.3290023'
'10/21/2013 13:11:34.4290008'
'10/21/2013 13:11:34.5289993'
'10/21/2013 13:11:34.6289978'
'10/21/2013 13:11:34.7289962'
I need to convert this cell to double,I used:
C =cellfun(@str2double,C,'un',0);
but it replaces all data with NaN !
can someone help me with that?
best, Navid
回答(1 个)
Azzi Abdelmalek
2014-4-12
编辑:Azzi Abdelmalek
2014-4-12
D={'10/21/2013 13:11:34.0289993'
'10/21/2013 13:11:34.1289978'
'10/21/2013 13:11:34.2289962'
'10/21/2013 13:11:34.3290023'
'10/21/2013 13:11:34.4290008'
'10/21/2013 13:11:34.5289993'
'10/21/2013 13:11:34.6289978'
'10/21/2013 13:11:34.7289962'}
s=regexp(D,'\.','split')
a=cellfun(@(x) x{1},s,'un',0)
b=cellfun(@(x) x{2},s,'un',0)
6 个评论
Navid
2014-4-12
Azzi Abdelmalek
2014-4-12
WHy D{1,1}(:,1) ?
Azzi Abdelmalek
2014-4-12
编辑:Azzi Abdelmalek
2014-4-12
The 7 digit are double or char? for example 0289993 if you convert it to double, it becomes 6 digits 289993
Azzi Abdelmalek
2014-4-12
Look at edited answer
Azzi Abdelmalek
2014-4-12
What this has to do with your initial question?
Navid
2014-4-12
类别
在 帮助中心 和 File Exchange 中查找有关 Calendar 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!