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!