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

2 次查看(过去 30 天)
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!

回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by