Can I convert empty strings to NaNs automatically in a cell array?
14 次查看(过去 30 天)
显示 更早的评论
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.
采纳的回答
MathWorks Support Team
2009-6-27
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!