non zero elements above 70 and below -70 zero
1 次查看(过去 30 天)
显示 更早的评论
hello people,
In a matrix I want that all non zero elements above 70 and below -70 is zero.
How do I do that ?
Thank you!
0 个评论
回答(4 个)
the cyclist
2012-2-17
I am not 100% sure what you mean, but here is some code (with comments on my understanding) that you should be able to modify to do what you want
% Some test data:
A = 200*rand(100) - 100;
% Index to values you want to zero out
idx = (A>70) | (A<-70); % Index to values that are bigger than 70 or smaller than -70
% Zero those out
A(idx) = 0;
carmen
2012-2-17
then you modify Honglei Chen 's approach according to your wish:
x(1:2,x(1:2,:)>70 | x(1:2,:)<-70)=0
that should be it.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multidimensional Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!