From: Pradeep Ramalingam on
i'm creating a matrix 10*10 in which 50% of them needs to be filled with number 3 and remaining 50% can be filled in random from 0 to 2... please help... need some assistance...
From: Darren Rowland on
A = floor(3*rand(10));
r = randperm(100);
A(r(1:50)) = 3;

Hth
Darren
From: Roger Stafford on
"Pradeep Ramalingam" <pradeep.ramalingam(a)gmail.com> wrote in message <htfsss$13i$1(a)fred.mathworks.com>...
> i'm creating a matrix 10*10 in which 50% of them needs to be filled with number 3 and remaining 50% can be filled in random from 0 to 2... please help... need some assistance...
- - - - - - - - -
m = 3*ones(10);
p = randperm(100);
m(p(1:50)) = floor(3*rand(50,1));

I am assuming here you intended the replacements to be integers 0, 1, and 2. Otherwise replace the floor(3*rand(50,1)) with 2*rand(50,1).

Roger Stafford