How to convert cell with numeric and string-nan into TYPE double
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
balandong
el 3 de Oct. de 2017
Comentada: balandong
el 5 de Oct. de 2017
Dear all, I have a cell with the combination of number and string NaN. May I know how I can convert the content into a double type? The cell is attach together with this thread.
Thanks in advance
0 comentarios
Respuesta aceptada
Matthew
el 3 de Oct. de 2017
Something like the below works fairly well. Use cellfun to search for numeric values, and save them into the doubles array. Then convert everything else into NaNs (or whatever else you want the NaNs to be).
cr_double = zeros(size(cr_manual))
cr_number = cellfun(@(x) isnumeric(x),cr_manual)
cr_double(cr_number) = [cr_manual{cr_number}]
cr_double(~cr_number) = NaN
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Type Conversion en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!