Converting Table Output from 1 Format to Another
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi I have the following output from a table my question is:
Which format is the best to manipulate the data ie Double/String etc and how to convert it to the new data, preferably Double?
Note this is not the width of the table but forms part of a 45 column table with the majority of data as Double.
A =
17×2 table
NNODSC Product Code
___________ _______________
16 {'28/0.85'} {'XHHP15AA001'}
25 {'43/0.85'} {'XHHP17AA001'}
35 {'24/1.35'} {'XHHP18AA001'}
50 {'34/1.35'} {'XHHP19AA001'}
70 {'30/1.7' } {'XHHP20AA001'}
95 {'30/1.7' } {'XHHP22AA001'}
120 {'48/1.35'} {'XHHP23AA001'}
150 {'48/1.35'} {'XHHP24AA001'}
185 {'48/1.35'} {'XHHP25AA001'}
240 {'48/1.35'} {'XHHP26AA001'}
300 {'48/1.35'} {'XHHP27AA001'}
400 {'48/1.35'} {'XHHP28AA001'}
500 {'48/1.35'} {'XHHP30AA001'}
630 {'48/1.35'} {'XHHP32AA001'}
800 {'48/1.35'} {'XHHP33AA001'}
1000 {'48/1.35'} {'XHHP34AA001'}
1200 {'48/1.35'} {'XHHP50AA001'}
Any advice will be helpful.
Thanks.
댓글 수: 3
Walter Roberson
2023년 2월 16일
Do you need to convert '28/0.85' to numeric 28 divided by 0.85, and so on?
답변 (1개)
Stephen23
2023년 2월 16일
편집: Stephen23
2023년 2월 16일
T = cell2table({'28/0.85','XHHP15AA001';'43/0.85','XHHP17AA001';'24/1.35','XHHP18AA001';'34/1.35','XHHP19AA001'},...
'VariableNames',{'NNODSC','Product Code'},'RowNames',{'16','25','35','50'})
F = @(C)double(split(string(C),'/'));
T = convertvars(T,'NNODSC',F)
T = splitvars(T,'NNODSC','NewVariableNames',{'NNODSC_L','NNODSC_R'}) % optional
댓글 수: 0
참고 항목
카테고리
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!