I want to generate a matrix of random numbers between 0 and 2.5 with length=8 and the sum of generated numbers be 20

6 visualizaciones (últimos 30 días)
I want to generate a matrix of random numbers between 0 and 2.5
The length of generated matrix should be 8 and the total sum of generated matrix should be 20.
need help
thanks in advance

Respuesta aceptada

the cyclist
the cyclist el 22 de Oct. de 2021
Editada: the cyclist el 22 de Oct. de 2021
Use the Random Numbers with Fixed Sum submission from the File Exchange.
  2 comentarios
Mausmi Verma
Mausmi Verma el 22 de Oct. de 2021
yes i have tried using that , but by calling the function using the values required in my code. it is returning all the 8 values same like this
2.5000
2.5000
2.5000
2.5000
2.5000
2.5000
2.5000
2.5000
now i am stuck with this of part in my coding
the cyclist
the cyclist el 22 de Oct. de 2021
I read your question a bit more closely.
Of course, there is only one way to have 8 numbers that sum to 20, if the max is 2.5, which is to have all the numbers equal 2.5.
So, this function has returned the correct and only answer.

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