How to find a value and set the following 2 value to NaN?
1 次查看(过去 30 天)
显示 更早的评论
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!