This extremely simple one-liner linearly interpolates between any two given points. The approximation is very simple and thus may not be very accurate, especially when the distance between the two points is large. However, due to its efficiency, it may be useful in a number of situations. See the images below to see a visual of how it works.

Matlab function [download]

function[yA]=linearinterpolation(x1,y1,x2,y2,A)
%Function requires two points (x1,x2),
%and evaluated values at those points (y1,y2), and point A
%between x1 and x2 for which you want to approximate y(A).
yA=y1+(A-x1)*((y2-y1)/(x2-x1));

R function [download]

linearinterpolation <- function(x1,y1,x2,y2,A) {
  #Function requires two points (x1,x2) and evaluated values at those points (y1,y2),
  #and point A between x1 and x2 for which you want to approximate yA.
  yA=y1+(A-x1)*((y2-y1)/(x2-x1));
}

Python function [download]

def linearinterpolation(x1,y1,x2,y2,A):
  yA=y1+(A-x1)*((y2-y1)/(x2-x1))
  return yA