MATLAB: Interpolation Between Two known data points

interp1

Hi everyone, I'm trying to do a complicated interpolation. I have two matrices and I'm trying to find the data points between these two.
One of my matrices is like this:
[80000 80000 80000 80000 80000 80000 ....
1.273 1.346 1.419 1.4926 1.5658 1.63897 ....]
and the second is like this:
[69000 69000 69000 69000 69000 69000 ....
5.022 5.367 5.712 6.058 6.4038 6.749 .....]
I'm trying to interpolate what the values of the second column would be given this data if the first column of data was all 75000, similar in structure to the other two. I want it to look like this:
[75000 75000 75000 75000 75000 75000...
___ ___ ___ ___ ____ ___ .....]
However anytime I try to use the interp1 function I get the error "Sample points must be unique and sorted in ascending order." because the first columns are not unique. I'm not sure how to go about this. Any suggestions are appreciated!

Best Answer

You're not looking across the variations in your two variables--another illustration why it's better to not create multiple variables for related data but to put into an array or other data structure that can reference programmatically -- see what happens if you were to use
X=[A(1,:);B(1,:)];
Y=[A(2,:);B(2,:)];
XO=75000;
YO=Y(1,:)+(XO-X(1,:))./diff(X).*diff(Y);
yields
>> YO
YO =
2.98 3.17 3.37 3.57 3.76 3.96
>>
for a single interpolant there's not much need for interp1
OTOH, you could use interp1 either in an anonymous function using the desired X0 and column(s) over which to interpolate as it isn't vectorized to accept more than a single vector X,Y input.