MATLAB: Replace String with a NaN in table

badMATLABnanstringtable

Hey guys!
I am challenged with a table, consisting various numbers and a few "'Bad'" cells. I guess they are strings. My goal now is to replace these "Bads" with NaNs.
How do I achieve that the easiest way?
Best regards, Spacey

Best Answer

It sounds like you imported a file where some of the columns were mostly numbers, but some strings mixed in. Best to avoid getting into the corner that you're in. You might have been able to explicitly say that the column is numeric. You might have been able to use the TreatAsEmpty parameter to readtable (if that's what you used).
Otherwise, if you have variables in the table that are cell arrays but that you want to be numeric, you might need to do one of a couple different things. In general, you need to put numeric things in all the cells and then concatenate the contents to get a numeric vector, but first you'll need to describe exactly what you have.