conversion of a dataset array
이전 댓글 표시
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
Matthew
2014년 4월 23일
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
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!