function [X,Y] = linear_interpolant(x,y,N) % We're given data in the vectors x and y. The output will be a % linear fitting where there are N-1 new points introduced between each % x(j) and x(j+1). n = length(x); j=1; dx = (x(j+1)-x(j))/N; xx = x(j):dx:x(j+1)-dx; X(1:N) = xx; Y(1:N) = (y(j+1)-y(j))/(x(j+1)-x(j))*(xx-x(j)) + y(j); for j=2:n-1 dx = (x(j+1)-x(j))/N; xx = x(j):dx:x(j+1)-dx; X((j-1)*N+1:j*N) = xx; Y((j-1)*N+1:j*N) = (y(j+1)-y(j))/(x(j+1)-x(j))*(xx-x(j)) + y(j); end X(N*(n-1)+1) = x(n); Y(N*(n-1)+1) = y(n);