How can I generate random number between 1 and 10, and at the same time I want to exclude number 3 & 6?

102 views (last 30 days)
How can I generate random number between 1 and 10, and at the same time I want to exclude number 3 & 6 using M-file?
  3 Comments

Sign in to comment.

Accepted Answer

Thorsten
Thorsten on 21 Mar 2019
x = setdiff(1:10, [3, 6]);
r = x(randi(numel(x)));

More Answers (0)

Community Treasure Hunt

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

Start Hunting!