Can I convert empty strings to NaNs automatically in a cell array?
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
In MATLAB, I have a cell array containing nonempty strings, numbers, and empty strings. I want to change the empty strings to NaNs using a MATLAB function.
Respuesta aceptada
MathWorks Support Team
el 27 de Jun. de 2009
The CELLFUN command provides this functionality:
% Return a boolean array named 'empties' (with same dimensions as cell array
% 'A') with true for each empty element and false otherwise
empties = cellfun('isempty',A);
% Now change all the empty cells in A from empty strings '' to double NaN
A(empties) = {NaN};
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import from MATLAB 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!