MATLAB: Use interp1 to interpolate a matrix row-wise

interp1matrixrow-wise

I am currently trying to expand some code to work with matrices and vectors instead of vectors and scalars. So the same calculations are to be done row-wise for n number of rows. How do I get interp1 to do this?
before I used something like this:
new_c = interp1(error,c,0,'linear',extrap')
It is used to find the value of c when an error approaches zero. Now I tried to just enter the matrices where each row is the same as the vector I used before and I get the error message "Index exceeds matrix dimensions".
I tried changing the zero to a vector of zeros but that did not help. I know I could solve it with a for-loop where I evaluate each row individually but I would prefer not to since I assume the matrix operation would save a lot of time.

Best Answer

Here is an example adapted from the online documentation ("doc interp1"):
x = 0:10;
y1 = sin(x);
y2 = 2*sin(x);
y = [y1;y2]';
xi = 0:.25:10;
yi = interp1(x,y,xi);
figure
plot(x,y,'o',xi,yi)