Make r a 1x5 vector using rand. Find the elements that have values <0.5 and set those values to 0 (use find).
4 ビュー (過去 30 日間)
古いコメントを表示
What would be the correct code for this? I have to use find in my answer.
0 件のコメント
採用された回答
ANKUR KUMAR
2017 年 12 月 30 日
Use any of these two codes will get you to the desired result.
A=rand(1,5)
A(A<0.5)=0
or
A(find(A<0.5))=0
その他の回答 (1 件)
Roger Stafford
2017 年 12 月 30 日
It is not necessary in Matlab to use 'find' for this problem. Do this:
r(r<0.5) = 0;
However, if you must use 'find', do this instead:
r(find(r<0.5)) = 0;
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!