Help with changing text in a table

5 ビュー (過去 30 日間)
gurjeevan singh
gurjeevan singh 2022 年 5 月 14 日
編集済み: gurjeevan singh 2022 年 5 月 14 日
Dear Sir/Madam,
I am fairly new to matlab and im having a problem with converting text in my table to different names. I have a table called X and under the column 'StepID' I have repeated characters of 'a to h' (8000 rows). I would like to change 'a' to 'protein A' and 'b' to 'VI' and 'c' to a different a name and so and and so forth until h. How could I implement this in Matlab.
Any help is greatly is greatly appreciated (using R2020b)
Best Regards,
Jeevs S


dpb 2022 年 5 月 14 日
catnames={'Protein A','VI','DI','AN', 'UF','CA','VRF','DF'};
results in
>> head(tSingh)
ans =
8×3 table
StepID M Step
______ _____ _________
{'a'} 0.00 Protein A
{'b'} 0.00 VI
{'c'} 0.00 DI
{'d'} 0.00 AN
{'e'} 0.00 UF
{'f'} 0.00 CA
{'g'} 10.00 VRF
{'h'} 5.71 DF
You can, of course, replace 'StepID' in place if don't need the original any longer...
NB: the shorthand to get the valueset list instead of the constructed's cleaner and is also sorted by unique()

その他の回答 (1 件)

dpb 2022 年 5 月 14 日
編集済み: dpb 2022 年 5 月 14 日
It's always bestest to attach a short section of your file/variable that illustrates...but will take a stab at it from the description.
Sounds like a place for a categorical variable instead of just string substitution -- try
catnames={'Protein A','VI', ...}; % DEFINE THE display names for each category
You didn't provide the full list; you'll have to create it to match as desired...
  3 件のコメント
gurjeevan singh
gurjeevan singh 2022 年 5 月 14 日
Thank you SO much ! It worked ! yay! saviour !
Best, Jeevs S





Community Treasure Hunt

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

Start Hunting!

Translated by