How to replace a string with another string in a Matlab table

10 Ansichten (letzte 30 Tage)
Hi,
I have a table that has 'N/A' in some of the column cells. I want to replace 'N/A' by ''. Would anyone tell me how to do that?
Thanks,
Jennifer

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 28 Aug. 2015
Example:
t.Var1(strcmp(t.Var1,'N/A')) = {''};
  6 Kommentare
Stephen23
Stephen23 am 7 Jan. 2023
Bearbeitet: Stephen23 am 7 Jan. 2023
"Please provide some code/hint to remove it"
Rather than removing them, the best approach is to avoid them in the first place (hint: as Walter Roberson already wrote, you can use the READTABLE options, e.g. TreatAsMissing). If you clicked the paperclip button to upload a sample data file then someone could probably help you with that.
Ashishkumar Gupta
Ashishkumar Gupta am 7 Jan. 2023
Thanks @Stephen23, Treatasmissing worked....I did not know the exactword to write in readtable(), that's y could not understand @Walter Roberson.
Now it worked!!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 27 Aug. 2015
Look at the isnan() function and I'm sure you'll find the way.

Tags

Noch keine Tags eingegeben.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by