MATLAB: I want to store all iteration value in the variable.

MATLAB

every time the loop are executing then the previous value are overwritten. so please give valuable solution.

Best Answer

Here is an example to avoid overwriting in a loop:
c=zeros(1,10); % preallocate for speed and efficiency
for i = 1:numel(c)
c(i)= 2^(i);
end
c