how to add empty in double array xxx = [ NaN 2 3 4 NaN]....Expected Value [ '' 2 3 4 '' ]
조회 수: 9 (최근 30일)
이전 댓글 표시
xxx=[nan 2 3 4 NaN]
xxx =
NaN 2 3 4 NaN
K>> class(xxx)
ans =
'double'
댓글 수: 0
답변 (1개)
Rik
2021년 12월 23일
That is not possible. You will either have to use a cell array, or remove the values entirely.
{'',2,3,4,''}
[2,3,4]
댓글 수: 1
Voss
2021년 12월 23일
To add on to this answer, here is how you might convert xxx to a cell array and replace the NaNs with '':
xxx = [NaN 2 3 4 NaN];
nan_idx = isnan(xxx);
xxx = num2cell(xxx);
xxx(nan_idx) = {''};
display(xxx);
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!