필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Is there a way to replace a specific NaN elements by integer where isnan would not work with steps greater than 1?

조회 수: 1 (최근 30일)
Hello All,
Could you please help with this problem
I have this matrix
hh=[NaN 1 2 3 4;3 5 66 NaN 6;NaN 3 4 7 NaN; 9 NaN 8 2 NaN];
and I want to replace only the NaN in some places to an integer. I have tried this hh(isnan(hh(1:2:4,1)))=1; which should replace the NaN in element (3,1) by 1 but did not work

답변 (1개)

Walter Roberson
Walter Roberson 2017년 7월 4일
mask = isnan(hh(:, 1)); mask(2:2:end) = false;
hh(mask) = 1;
  댓글 수: 2
Abdulaziz Abutunis
Abdulaziz Abutunis 2017년 7월 4일
Thank you Walter, I tried your example and it will replace all the NaN in the first column. Best
Walter Roberson
Walter Roberson 2017년 7월 5일
isnan(hh(1:2:4,1)) is true for hh(1,1) so you have indicated that you do want hh(1,1) to be replaced.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by