How to create randi function between 0-500

조회 수: 20 (최근 30일)
Gil Tulian
Gil Tulian 2021년 10월 15일
댓글: Image Analyst 2021년 10월 15일
Hi,
I have been asked to do a randi function between 0-500 with 50 organs.
I succed to made randi function with 500 max and with 50 organs, but how I should do it between 0-500? and not just 1-500?

답변 (1개)

Scott MacKenzie
Scott MacKenzie 2021년 10월 15일
편집: Scott MacKenzie 2021년 10월 15일
Just use the imin-imax version of randi. For example
n = randi([0, 500], 50, 1);
generates a column vector of random integers in the range 0 to 500.
  댓글 수: 3
Scott MacKenzie
Scott MacKenzie 2021년 10월 15일
You're welcome. Glad to help.
Image Analyst
Image Analyst 2021년 10월 15일
@Gil Tulian, please click the "Accept this answer" link to award Scott the Reputation Points he deserves for helping you. Thanks in advance. 🙂

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

카테고리

Help CenterFile Exchange에서 Naming Conventions에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by