MATLAB: Fit a curve so that a part of it is the same as another curve

affine

I have a 1d array 'a' and a 1d array 'b'.
'a' is a length m and 'b' is a length n, where m>n.
I want to transform the array 'a' such that
a(1:n)=b
but also such that
a(n+1:m)
is also transform, i.e. so that the transformation is performed to the full array 'a' in matlab.
Is this possible in Matlab?

Best Answer

I am not certain what you want to do. The two functions that are most likely to give you the desired resultl are linspace (link) and interp1 (link). You will probably need to use both of them together.
EDIT —
With the new information, use interp1:
a = 1:10;
b = [2 4 6 8];
newa = interp1((1:4), b, a, 'linear', 'extrap')
producing:
newa =
2 4 6 8 10 12 14 16 18 20