
function x = lin_interp(a, y, f, n_y)
% interpolate
%	Given a function f(y), where y is a discrete set of values that doesn't include
%  a, interpolate calculates f(a) by doing linear interpolation (i.e. a weighted 
%  average of the values of f(y) on either side of the new point, a).
%		Note that the values of y(i) from i = 1 to i = n_y need to be in ascending
%	order.

% ARGUMENTS:
%				a		new point at which the function is to be calculated
%				y		array, the y-axis values
%				f		array, the function
%				n_y	length of the y & f arrays
%
% INPUT FILES: 	zilch (i.e. none)
%
% CALLS:				binary_search
%
% CALLED BY:		read.m
%
% COMMENTS:
%	Remember that MatLab only (as far as I can tell) passes variables to functions
%	by _value_. So the arrays that are passed here from the calling script cannot
%	be modified. I think that that's worth mentioning, because I spent quite a while
%	trying to fix a bug on another function that was due to my being ignorant of
%	this fact. 

% I think binary_search handles this...
%if (a >= y(n_y))
%   disp('LIN_INTERP.M: argument out of bounds.');
%   x = f(n_y);
%end   
%if (a <= y(1))
%	disp('LIN_INTERP.M: argument out of bounds.');
%   x = f(1);
%end

n_a = binary_search(a, y, n_y, 1);

% actually...I don't really need this function anymore.




