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

dpb
dpb 2017년 9월 13일
What does this mean (the "per second part at least)???

댓글을 달려면 로그인하십시오.

답변 (2개)

Akira Agata
Akira Agata 2017년 9월 13일

1 개 추천

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 2017년 9월 13일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Random Number Generation에 대해 자세히 알아보기

질문:

2017년 9월 13일

답변:

2017년 9월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by