function y=linear(x0,y0,x1,y1,xi) % for (x0 <= xi <= x1), find yi by linear interpolation slope=(y1-y0)/(x1-x0); xd=xi-x0; y=y0 + slope*xd;