Creating regenerative random numbers
1 回表示 (過去 30 日間)
古いコメントを表示
The code creates 10 random ellipses
N = 10;
for R = 1:N %for loop to repeat 10 times
t = linspace(0,2*pi); % t defined angle??? not sure
xc = randn; %defines one of axis as random
x = xc + randn*cos(t);
yc = randn;
y = yc + randn*sin(t);
plot(x,y)
patch(x,y,rand)
hold on %puts all ellipses on same graph
end
How do I add to the code to make it so that everytime i run this code i get the same graph with the same random numbers inputed?
0 件のコメント
回答 (1 件)
Walter Roberson
2021 年 3 月 3 日
rng(655321) %or use any other positive integer constant
3 件のコメント
Steven Lord
2021 年 3 月 3 日
This documentation page has more information about controlling the random number generator.
参考
カテゴリ
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!