How to find a value and set the following 2 value to NaN?
2 ビュー (過去 30 日間)
古いコメントを表示
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?
0 件のコメント
採用された回答
madhan ravi
2018 年 12 月 16 日
A=randi(10,1,10).'
idx=find(A==1);
A([idx idx+1 idx+2])=NaN
3 件のコメント
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.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Resizing and Reshaping Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!