How Can i Produce a Random mxn Matrix, with pre -specified set of integers?!

6 views (last 30 days)
Hi :P I need to generate a random mxn matrix with elements either -1 or 1 only.

Accepted Answer

Wayne King
Wayne King on 14 Oct 2013
Edited: Wayne King on 14 Oct 2013
X = randi([0 1],20,20);
X(X==0) = -1;

More Answers (0)

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!