conversion of a dataset array
10 次查看(过去 30 天)
显示 更早的评论
Hi.
I have the following dataset:
ID SP MD FI
'1234' 'BBB-' 'Baa3' []
'1235' [] [] 'A-'
'1236' 'BB' 'Ba1' 'BB+'
'1237' 'A' 'A3' []
This table was created from a cell to dataset.
Now I know it looks like it but ID is not a string (I think) and I'm trying to do a str2num and this is failing.
Does anyone know how to convert ID into a number?
1 个评论
Andreas Justin
2014-4-22
编辑:Andreas Justin
2014-4-22
str2double?
ds = cell2dataset({'ID';'123';'1234'});
str2double(ds.ID)
ans =
123
1234
回答(1 个)
Azzi Abdelmalek
2014-4-22
A={'ID' 'SP' 'MD' 'FI'
'1234' 'BBB-' 'Baa3' []
'1235' [] [] 'A-'
'1236' 'BB' 'Ba1' 'BB+'
'1237' 'A' 'A3' []}
B=cell2dataset(A)
B.ID=str2double(B.ID)
2 个评论
Andreas Justin
2014-4-23
could you show us the value of NEWNAMES when this error happens?
and the line of code you're using cell2dataset
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!