Make r a 1x5 vector using rand. Find the elements that have values <0.5 and set those values to 0 (use find).
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Lauren Oliveri
am 30 Dez. 2017
Bearbeitet: Lauren Oliveri
am 30 Dez. 2017
What would be the correct code for this? I have to use find in my answer.
0 Kommentare
Akzeptierte Antwort
ANKUR KUMAR
am 30 Dez. 2017
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 Kommentar
Weitere Antworten (1)
Roger Stafford
am 30 Dez. 2017
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 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!