picking a random number in a range

hello i have a problem
I can explain this problem as follows;
I want to randomly pick a number between 1 and 69 points. I want the selected number to change every time I run it.
this is my cod; cpoint=unidrnd(69-1);
but this code gives error. How can I do it
Thanks advance.

답변 (1개)

Steven Lord
Steven Lord 2022년 5월 18일

0 개 추천

Do you want a random integer value or just any old number between 1 and 69?
The next time you draw a random number, are you going to want to exclude the previously drawn number (like if you're simulating a lottery drawing, where once a numbered ball is drawn it cannot be drawn again)?
Take a look at the randi (random integers with replacement), randperm (random integers without replacement), or rand (random numbers) functions.

댓글 수: 1

Esra Demirbilek
Esra Demirbilek 2022년 5월 18일
I want to pick random integers between 1 and 69. I can re-select the number I chose.
I am working on genetic algorithm.
I will cross between two individuals. I need the cutting point to be able to crisscross. I want to randomly select an integer between 69-1 for the cut-off point. I want the number I selected to change every time I run the code.

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

카테고리

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

제품

릴리스

R2021a

질문:

2022년 5월 18일

댓글:

2022년 5월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by