function [xo,yo] = growlin(x,y,n); % % Function to use linear interpolation to increase % the number of points in a table to n+1. % Generate x coordinates for new table xo = linspace(x(1),x(end),n+1)'; % Loop over these points to find corresponding y. Skip the % first and last points in the table because these are the % same as the original data yo(1) = y(1); yo(n+1) = y(end); for i = 2:n % Locate position of xo(i) in original table loc = find(x < xo(i)); loc = loc(end); % Get points on either side of xo(i) x1 = x(loc); x2 = x(loc+1); y1 = y(loc); y2 = y(loc+1); % Slope and y-intercept m = (y2-y1)/(x2-x1); b = y1-m*x1; % Use line to get yo(i) yo(i) = m*xo(i)+b; end yo = yo(:);