Info

This question is closed. Reopen it to edit or answer.

if r=rand(2,8) . I wanna find every element which is smaller than 0.5 and replace it with any other number say 0 or 1 or 2. how to do it....??

1 view (last 30 days)
if r=rand(2,8) . I wanna find every element in r which is smaller than 0.5 and replace it with any other number; say 0 or 1 or 2. how to do it....??

Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 9 Nov 2013
  3 Comments
Michael
Michael on 9 Nov 2013
IF you need you could find even more particular values using logical AND & (here && since scalar) or logical OR |
r(0.3<r && r<0.5) = 59
r(0.2>r || r>0.99) = 13
such as the above. Good Luck.

Community Treasure Hunt

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

Start Hunting!