change name of a variable inside a loop [duplicate]

You should preallocate a matrix before your loop, and in the loop you just insert the vectors directly in the columns (or rows). Like:

A= zeros(10, 10);
for k in 1: 10
    A(:, k)= %# result of your processing
end

Leave a Comment