Hi I have a matrix of 3 * 3 and I want to fill it by 4 value of 1, 3 value of 2 and 2 value 2 no matter the location I tested this code but I did not find the desired result.
function [matrice] = hyperImage(dim , n1 ,n2 ,n3 ) %% n1: number of 1 ,n2: number of 2,n3: number of 3
matrice=zeros(dim,dim); %%Fill a desired domention matrix with a value of zero
d=dim-1;
for i=1:n1 r=round(rand*d)+1; c=round(rand*d)+1; matrice(r,c)=1; end for i=1:n2 r=round(rand*d)+1; c=round(rand*d)+1; matrice(r,c)=2; endfor i=1:n3 r=round(rand*d)+1; c=round(rand*d)+1; matrice(r,c)=3;end
Best Answer