Clear Filters
Clear Filters

Make r a 1x5 vector using rand. Find the elements that have values <0.5 and set those values to 0 (use find).

1 view (last 30 days)
Confused on how to write this code,
r = rand(1,5); find(r<0.5)=0
tried that, didnt work. anything help. Thanks in advance!

Answers (1)

Walter Roberson
Walter Roberson on 18 Sep 2016
idx = find(r<0.5);
Now think about r(idx)

Community Treasure Hunt

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

Start Hunting!