Effacer les filtres
Effacer les filtres

Converting Table Output from 1 Format to Another

1 vue (au cours des 30 derniers jours)
Frank Lehmann
Frank Lehmann le 16 Fév 2023
Modifié(e) : Stephen23 le 16 Fév 2023
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 commentaires
Walter Roberson
Walter Roberson le 16 Fév 2023
Do you need to convert '28/0.85' to numeric 28 divided by 0.85, and so on?
Frank Lehmann
Frank Lehmann le 16 Fév 2023
Walter,
No, I just want the expression as an example 48/1.35 is what I want, not 35.555 as the result of a divisible number?
I would just to be able to manipulate the data in whatever format is appropriate?
Cheers,
Frank

Connectez-vous pour commenter.

Réponses (1)

Stephen23
Stephen23 le 16 Fév 2023
Modifié(e) : Stephen23 le 16 Fév 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'})
T = 4×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'}
F = @(C)double(split(string(C),'/'));
T = convertvars(T,'NNODSC',F)
T = 4×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'}
T = splitvars(T,'NNODSC','NewVariableNames',{'NNODSC_L','NNODSC_R'}) % optional
T = 4×3 table
NNODSC_L NNODSC_R Product Code ________ ________ _______________ 16 28 0.85 {'XHHP15AA001'} 25 43 0.85 {'XHHP17AA001'} 35 24 1.35 {'XHHP18AA001'} 50 34 1.35 {'XHHP19AA001'}

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by