generate random number between positive and negative and sum of this number is zero
7 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
More Answers (1)
Voss
on 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 Comments
Voss
on 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
See Also
Categories
Find more on Random Number Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!