Hi,
I tried to fix the errors (cut and paste some lines inside the inner for loop), and added outer for loop for 10 times calculation(I assume your random variable a changes in every iteration).
Try this below. It takes a little bit long time since I ended up with conmat 2048x2048 matrix. But maybe there could be a high performanced version of it.
conmat = [0 1; 1 0] ;
for m=1:10
S=size(conmat,1);
r=randi(S);
sigma=0.3;
a=rand;
for j=1:size(conmat,1)
rowadd=zeros(1,size(conmat,1));
rndrow=conmat(r,:);
if sigma > a
rowadd= rndrow;
elseif sigma < a
end
conmat=[conmat; rowadd];
coladd=transpose(conmat(3,:));
coladd=[coladd; 0];
conmat=[conmat coladd];
end
end
If you want to replicate matrices you can use repmat function also. Here the link: repmat
Best Answer