How to generate a random number that is either 100, 200, or 300.

조회 수: 4 (최근 30일)
Karl
Karl 2022년 10월 7일
댓글: Karl 2022년 10월 8일
Hello, I'm looking for a way to generate a random number that is either those 3 choices (nothing in between), utilizing only the rand, randi, round, floor, or ceil methods.

채택된 답변

Image Analyst
Image Analyst 2022년 10월 8일
As long as it's not your homework, you can use my code:
r = 100 * randi(3, 1)

추가 답변 (1개)

Torsten
Torsten 2022년 10월 7일
Hint:
100*1 = 100
100*2 = 200
100*3 = 300
  댓글 수: 3
John D'Errico
John D'Errico 2022년 10월 8일
Yes. there is a way. @Torsten showed you how.
Karl
Karl 2022년 10월 8일
He definitely did and it flew over my head.

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

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by