generate random number between positive and negative and sum of this number is zero
7 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
その他の回答 (1 件)
Voss
2022 年 4 月 12 日
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 件のコメント
Voss
2022 年 4 月 12 日
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
参考
カテゴリ
Help Center および File Exchange で Random Number Generation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!