generate random number between positive and negative and sum of this number is zero
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
kukuh widarsono
el 12 de Abr. de 2022
Comentada: Voss
el 12 de Abr. de 2022
I want generate random number between positive and negative, and then the sum of this number equal to zero. what have I should do?
0 comentarios
Respuesta aceptada
Más respuestas (1)
Voss
el 12 de Abr. de 2022
x = randn(); % random number from standard Normal distribution
y = -x; % another number such that the sum of x and y is 0
x
y
x+y
2 comentarios
Voss
el 12 de Abr. de 2022
x = randn(5); % 5x5 random matrix from standard Normal distribution
y = -x; % another matrix such that the sum of x and y is 0
x
y
x+y
Ver también
Categorías
Más información sobre Random Number Generation 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!