I have coded the attached loop to update matrix Lr but I would ideally like to use code that can achieve what the shown loop is doing in one sweep (i.e. without needing to loop); the actual matrixes I have can be extremely large.
The code is also shown below, but the layout is off:
k = 1;pos_neg = [1;1;0];E = [round(rand(1,3));round(rand(1,3));round(rand(1,3))];Lr = zeros(numel(pos_neg(:,1)),numel(E(:,1)));L = 0.5;for i = 1:numel(E(:,1)) for ii = 1:numel(E(:,1)) if sum(E(i,:)) <= k if E(i,ii) == 0 Lr(i,ii) = L; end if E(i,ii) == 1 Lr(i,ii) = -L; end end if sum(E(i,:)) >= k if E(i,ii) == 1 Lr(i,ii) = L; end if E(i,ii) == 0 Lr(i,ii) = -L; end end endend
Best Answer