# extrapolate three points between line

I have a line with known starting and ending 'x' and 'y' coordinates. I want to extrapolate three more between x and y points in MATLAB. I tried to find a lot but I couldn't get any help regarding extrapolate. Anyone please help me in this.

• Extrapolation requires at least some additional information on "where" you want to extrapolate, unless you want regular extrapolation. Could you please add more specifications? Plus, when you want points between, it is generally called "interpolation", for which you might find more information. Could you please rewrite your title accordingly? – Laurent Duval Oct 30 '15 at 18:32
• look up the "Two-point formula". – robert bristow-johnson Aug 20 '16 at 22:40

As you interpolate a line, I assume it is a linear interpolation. The solution reduces to a linear combination of the intial starting and ending coordinates. For instance, $i_1 = \frac{1}{3}s + \frac{2}{3}e$ and $i_2 = \frac{2}{3}s + \frac{1}{3}e$ provide the coordinates of two interpolation points $i_1$ and $i_2$ between start point $s$ and end point $e$.

clear
%% Initialization
pStart =[1 3]';
pEnd = [4 2]';
nPointInter = 3;

%% Interpolation weights (including pStart and pEnd)
lInterval = linspace(0,1,nPointInter+2);

%% Interpolation coordinates
pInterp = pStart*lInterval+pEnd*(1-lInterval);

%% Display
figure(1);clf
hold  on
plot(pInterp(1,:),pInterp(2,:),'xb')
plot([pStart(1) pEnd(1)]',[pStart(2) pEnd(2)]','or')
grid on


The result will be: 