MATLAB: How to increase the columns of an NxM matrix to become NxN? (N>M) Not using reshape.

interpolationmatricesmatrix manipulation

Hi all,
I was hoping somebody could help me with this. Essentially, I have a 50×10 matrix and I want the matrix to be 50×50. I am trying to insert a couple of columns in between each column that I already have and then I want to make sure the values that are inserted have a linear trend between them. Here is an example of what I am trying to say:
A = [0 4 5;
0 5 1;
10 8 1;
2 4 6;
1 2 3] (5x3)
and I want the new matrix to be:
Anew = [0 2 4 4.5 5;
0 2.5 5 3 1;
10 9 8 4.5 1;
2 3 4 5 6;
1 1.5 2 2.5 3] (5x5)
Doing this by hand is easy for an example this small, but is there a way to do this via computations, or a function? I need to be able to do it for much larger matrices.
I hope my question is clear. Thanks in advance.

Best Answer

This works:
vi = linspace(1, 3, 5); % Interpolation Vector
for k1 = 1:size(A,1)
Anew(k1,:) = interp1([1:3], A(k1,:), vi, 'linear');
end