How to replace different values with NaN in a matrix.

조회 수: 3 (최근 30일)
Paul Hinze
Paul Hinze 2020년 11월 11일
댓글: Paul Hinze 2020년 11월 11일
Hey guys,
I have this matrix:
Matrix = [50 51 52 53 54 55; 110 111 112 113 114 115; 1 0 0 1 0 0]'
how can i change the values of the second column to NaN, when there is a zero in the third clumn???

답변 (1개)

Stephen23
Stephen23 2020년 11월 11일
Matrix = [50 51 52 53 54 55; 110 111 112 113 114 115; 1 0 0 1 0 0].'
Matrix = 6×3
50 110 1 51 111 0 52 112 0 53 113 1 54 114 0 55 115 0
idx = Matrix(:,3)==0;
Matrix(idx,2) = NaN
Matrix = 6×3
50 110 1 51 NaN 0 52 NaN 0 53 113 1 54 NaN 0 55 NaN 0

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by