Creating regenerative random numbers

1 visualización (últimos 30 días)
Emma
Emma el 3 de Mzo. de 2021
Comentada: Steven Lord el 3 de Mzo. de 2021
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?

Respuestas (1)

Walter Roberson
Walter Roberson el 3 de Mzo. de 2021
rng(655321) %or use any other positive integer constant
  3 comentarios
Emma
Emma el 3 de Mzo. de 2021
nevermind got it!
Steven Lord
Steven Lord el 3 de Mzo. de 2021
This documentation page has more information about controlling the random number generator.

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by