필터 지우기
필터 지우기

How to find a value and set the following 2 value to NaN?

조회 수: 1 (최근 30일)
Emmanouil  Rachoutis
Emmanouil Rachoutis 2018년 12월 16일
댓글: Emmanouil Rachoutis 2018년 12월 18일
Hi :) I have a vector let's say A=randi(10,1,100)' and whenever I find a value equal to 1 I want to set that value and the following 2 values to NaN.
For another case I need to do the same but whenever there are 4 ones in row, then I need to do set to NaN the 2 values following the last 1.
Does anyone know a way of doing that?

채택된 답변

madhan ravi
madhan ravi 2018년 12월 16일
A=randi(10,1,10).'
idx=find(A==1);
A([idx idx+1 idx+2])=NaN
  댓글 수: 3
madhan ravi
madhan ravi 2018년 12월 18일
편집: madhan ravi 2018년 12월 18일
Anytime :) , let me get back to you in a few minutes , you can either unaccept my answer or pose it as a separate question so that others may answer you.
Emmanouil  Rachoutis
Emmanouil Rachoutis 2018년 12월 18일
Thanks once again :) I actually had included this question in the main question ;)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by