MATLAB: How to remove the index number

removing the index number

Could anybody help me how to remove the index number in for loop for the code mentioned below under the scenario it should not get repeated again in other group and for each run the matrix A should be updated.
A = diag([1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]);
N_G=4;%No of group
B = cell(N_G,1);
sumB = cell(N_G,1);
%

for i=1:1:N_G
n=randi([1 15],1)% select No of UE randomly
idx=randsample(1:size(A,2),n)
B{i} = A(idx,:)
%
[rows, columns] = size(B{i})
% Get sum of columns and replicate vertically.
sumB{i} = repmat(sum(B{i}, 1), [rows, 1])
end

Best Answer

It's not clear what you mean. A for loop has to have an index (loop iteration variable), though you're free to use it or ignore it in the loop. Also if you want A to change (somehow) in the loop, you're going to have to have A on the left side of an equals sign.