MATLAB Answers

How can I change the elements to zero when they are less than specific threshold

2 views (last 30 days)
I have A = [1,10,4,8,25,80,1,4,8]
I want to put zerpo those elements which are less than 5
in fact, 5 is my threshold

Accepted Answer

Adam Danz
Adam Danz on 13 Sep 2020
Edited: Adam Danz on 13 Sep 2020
A(A<5) = 0;
A(A<=5) = 0;
B = A .* double(A>5);
B = A .* double(A>=5);
Try them out and choose one.
  3 Comments

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by