how to do this?
i want to place a specific number, like number 2 randomly into a 3x3 of zeros array,
it did came out, but the coding still not right and somehow number 1 also appear.
rows = 3;
cols = 3;
M = zeros(rows,cols);
p = randi(2);
rV = randperm(rows);
cV = randperm(cols);
M(rV(2),cV(2))=p
where did i do wrong? any suggestion
M(randi(numel(M)))=2?