I want to sample my data (V) at the sampling positions specified in X. Target contains the coordinates of the V values. X is a set of increasing values. If X is not found in target, then interpolation is used to calculate the V value. Target is same length as V. So we might have:
X=[5.5 10 13]V=[1 2 3 4 5 6 7]target=[2 4 6 8 10 12 14]
So the X values are looked for in target, and linear interpolation is used to provide a V value at the same index in V, hence:
desired output = [2.75 5 6.5]
I thought this would be a job for interp1 but it is not because X and V are not equal, i.e. output=interp1(X,V,target); X will always be within the range of target and V and target will always be the same length. Am I missing something simple here?
Best Answer