MATLAB: Operate column-wise in a loop

for loop

I have an n x m matrix. I want to extract each column and do some operations, say 2D interpolation of each column to different grids, and then replace corresponding columns with the new data. How can I do it in a loop?
Regards,
RPJ

Best Answer

Let A be your nxm matrix.
for i=1:m
Aci = A(:,i) ; %pick column
% use interp1, let result be Acii
A(:,i)=Acii ;% replace column
end