Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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!

Respuestas (1)

Walter Roberson
Walter Roberson el 18 de Sept. de 2016
idx = find(r<0.5);
Now think about r(idx)
  2 comentarios
Walter Roberson
Walter Roberson el 18 de Sept. de 2016
find does not return values, find returns locations, also known as indices, which is often abbreviated to idx in English (because the singular of "indices" is "index")

Iniciar sesión para comentar.

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by