How to pick random number?

42 views (last 30 days)
Rose on 2 Oct 2013
Commented: Dennis M on 27 Feb 2021
Hi, Please forgive me if I am asking a basic question. I want to pick random number from the set {2,3}. It should either pick 2 or 3 randomly. I have been looking at these functions called 'rand', 'randi', 'randperm' etc., but i couldn't figure out how to use them for my problem. Any help would be appreciated.

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 2 Oct 2013
Edited: Azzi Abdelmalek on 2 Oct 2013
randi([2 3])
v=[2 3];
Dennis M
Dennis M on 27 Feb 2021
Thank you Azzi Abdelmalek, you help me too... God Bless

Sign in to comment.

More Answers (0)


Community Treasure Hunt

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

Start Hunting!