generate random number between positive and negative and sum of this number is zero
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
kukuh widarsono
am 12 Apr. 2022
Kommentiert: Voss
am 12 Apr. 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 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Voss
am 12 Apr. 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 Kommentare
Voss
am 12 Apr. 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
Siehe auch
Kategorien
Mehr zu Random Number Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!