How to get Random numbers only from -1 1 and 2?
Show older comments
I need to create a random integer numbers generator which only creates -1,1 and 2
here is my code for 1 or 2:
for m=1:100
A=randi([-1 2]);
A
end
Accepted Answer
More Answers (1)
madhan ravi
on 26 Dec 2018
P=[-1 1 2];
A=P(randi([1 numel(P)],1,100))
Categories
Find more on Random Number Generation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!