%% tecmin.m is the function file used to determine the required
%% offset (scalar) to minimise the difference between two sets 
%% of data.

function chi=tecmin(pp,tec1,tec2,wt)

% pp = offset parameter
% tec1 = TEC data to be 'moved'
% tec2 = TEC to remain satationary
% wt = weighting of term
% chi = minimized value

chi=sum(wt.*((tec1+pp)-tec2).^2);