Converting Table Output from 1 Format to Another
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Walter Roberson
il 16 Feb 2023
Do you need to convert '28/0.85' to numeric 28 divided by 0.85, and so on?
Risposte (1)
Stephen23
il 16 Feb 2023
Modificato: Stephen23
il 16 Feb 2023
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 Commenti
Vedere anche
Categorie
Scopri di più su Data Type Conversion in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!