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!