how can i initialize a matrix (20/5) with random 0 and 1s

6 visualizaciones (últimos 30 días)
matrix consist of random numbers between (-10,10) in binary

Respuesta aceptada

José-Luis
José-Luis el 6 de Sept. de 2016
result = rand(20,5);
result = result > 0.5;
  2 comentarios
reddysekharreddy sadu
reddysekharreddy sadu el 6 de Sept. de 2016
can you please explain meaning of second line @joseluis
José-Luis
José-Luis el 6 de Sept. de 2016
rand gives numbers between 0 and 1. The second line will replace those numbers with 1 if they are larger than 0.5 and 0 otherwise.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices 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