How do I convert a cell array with string, double, and NaN values to a double array
조회 수: 9 (최근 30일)
이전 댓글 표시
I have a cell with these values = {1, 2, 'None', 1, 2, 3, 5, NaN, 'None'}
I want to convert this into a double with these values = {1, 2, NaN, 1, 2, 3, 5, NaN, NaN}
Is this possible?
댓글 수: 0
채택된 답변
jonas
2018년 9월 5일
편집: jonas
2018년 9월 5일
My original solution was obviously flawed, so credits to Guillaume for cleaning up redundant functions
A(strcmp(A, 'None')) = {NaN};
cell2mat(A)
A(~cellfun(@isnumeric,A)) = {NaN}
댓글 수: 3
jonas
2018년 9월 5일
Thanks guys! I put your solutions in the answer box for future reference, as the answer had already been accepted.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!