Convert zeros to NAN
조회 수: 5 (최근 30일)
이전 댓글 표시
I have a matrix (N rows and M columns). It consists of integer values. I want to convert all the zero values from rows 1:N and columns 3:M to NaN. Is there any way to do so.
Thanks, Nancy
댓글 수: 0
채택된 답변
Sean de Wolski
2011년 6월 14일
One of many ways
idx = ~A;
idx(:,1:2) = false;
A(idx) = nan;
댓글 수: 3
Sean de Wolski
2011년 6월 14일
Yes. It sets any value that was a zero value (the ~ (not) command) in the first definition to be false so that it doesn't show up in the nan assignment.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Numeric Types에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!