How do I convert a cell array with string, double, and NaN values to a double array
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Akul Satish
am 5 Sep. 2018
Bearbeitet: Stephen23
am 5 Sep. 2018
I have a cell with these values = {1, 2, 'None', 1, 2, 3, 5, NaN, 'None'}
I want to convert this into a double with these values = {1, 2, NaN, 1, 2, 3, 5, NaN, NaN}
Is this possible?
0 Kommentare
Akzeptierte Antwort
jonas
am 5 Sep. 2018
Bearbeitet: jonas
am 5 Sep. 2018
My original solution was obviously flawed, so credits to Guillaume for cleaning up redundant functions
A(strcmp(A, 'None')) = {NaN};
cell2mat(A)
A(~cellfun(@isnumeric,A)) = {NaN}
3 Kommentare
jonas
am 5 Sep. 2018
Thanks guys! I put your solutions in the answer box for future reference, as the answer had already been accepted.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!