Generate random numbers per second

Hi, I want to generate random numbers per second in range of 1 to 20 and also draw them on a graph immediately. How can I code this in MATLAB? THX

1 comentario

dpb
dpb el 13 de Sept. de 2017
What does this mean (the "per second part at least)???

Iniciar sesión para comentar.

Respuestas (2)

Akira Agata
Akira Agata el 13 de Sept. de 2017
The code for your question might be like this. But I'm not sure why this kind of code is needed... (I would be happy if you could tell us more detail behind your question! )
data = [];
figure
for kk = 1:100
data = [data, randi(20)];
plot(data,'o-');
pause(1);
end
Steven Lord
Steven Lord el 13 de Sept. de 2017

0 votos

Take a look at the rand, randn, or randi functions in MATLAB or the random number generation functions in Statistics and Machine Learning Toolbox (depending on the distribution from which you want to draw your random numbers.)
For the plotting, see if animatedline does what you want.

Categorías

Más información sobre Random Number Generation en Centro de ayuda y File Exchange.

Preguntada:

el 13 de Sept. de 2017

Respondida:

el 13 de Sept. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by