I am trying to create a random 10x10 matrix that each row is equal to a certain value, what would be the best way of carrying this out?

3 visualizaciones (últimos 30 días)
How to set the sum of each row in a matrix to a certain value when creating a random matrix

Respuestas (2)

Walter Roberson
Walter Roberson el 14 de Feb. de 2017

Roger Stafford
Roger Stafford el 16 de Feb. de 2017
As Walter has stated, you can use the routine I contributed to the File exchange called “randfixedsum” for each of your ten rows. However, that function does require that you specify a lower and an upper limit for each of the ten elements for any given row. That is something you would need to decide.
  2 comentarios
Roger Stafford
Roger Stafford el 16 de Feb. de 2017
Yes it would work, but you would have to call on randfixedsum ten different times in a for-loop using the different desired sums (and possibly different allowed ranges.)

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by