MATLAB: How to get a variable from inside of the for loop and use it after it ends

outside a loop

if (M ~= M2)
C=padarray(x,[21,0],0,'post');
sz=size(C)
end
I would like to use 'sz' outside the loop for the rest of my code

Best Answer

if you want the value of the variable at a certain point in the for loop,you can save it in a different variable at that iteration then after the for loop is finished save it back int its original variable name