generate random number between positive and negative and sum of this number is zero
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Plus de réponses (1)
Voss
le 12 Avr 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 commentaires
Voss
le 12 Avr 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
Voir également
Catégories
En savoir plus sur Random Number Generation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!