Help with changing text in a table
古いコメントを表示
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
採用された回答
その他の回答 (1 件)
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
tX.Step=categorical(cellstr(tX.Step),cellstr(['a':'h'].'),catnames);
You didn't provide the full list; you'll have to create it to match as desired...
3 件のコメント
gurjeevan singh
2022 年 5 月 14 日
編集済み: gurjeevan singh
2022 年 5 月 14 日
That's a fignewton of the cut' n paste from the command line I didn't see...the ">>" command prompt doesn't belong in there; not sure how it did get there, but..
catnames={'Protein A','VI', ...}; % DEFINE THE display names for each category
tX.Step=categorical(cellstr(tX.Step),cellstr(['a':'h'].'),catnames);
will have a much better chance....
gurjeevan singh
2022 年 5 月 14 日
編集済み: gurjeevan singh
2022 年 5 月 14 日
カテゴリ
ヘルプ センター および File Exchange で Time Series Objects についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!