% initPosfixSGMP.m
%---------------------------------------------------------
% initialize environment and variables
% Ju-Yong Do,  Feb 3, 2009
%=========================================================
%=========================================================
%load data and parameters
paraPosfixSGMP;                     %program parameters
load(filename);                     %load data file
result      = [];                   %record of all results
result.numepoch = size(rx.meas,2);  %number of epochs
disp('=============================================================');
disp(['Position estimation from "',filename,'" with ',num2str(result.numepoch),' epochs']);

%=========================================================
%set variables
est.oldpos = wgslla2xyz(37.43,-122.17, 0)';%seed location is stanford university
if isfield('rx.info','initpos')     %use initial position as seed if available   
    if ~isempty(rx.info.initpos), 
        est.oldpos = rx.info.initpos;
    end
end
est.oldclkbias = 0;                 %seed clk bias
est.rotmat  = calRotMat(est.oldpos);%rotation matrix
est.pos     = [];                   %position estimate
est.clkbias = [];                   %clock bias estimate
est.valid   = 0;                    %validity flag of current epoch data
est.tow     = [];                   %time of week
est.pdop    = [];                   %position dop
est.hdop    = [];                   %horizontal position dop
est.vdop    = [];                   %vertical position dop
est.tdop    = [];                   %time dop (could be multiple)
est.gdop    = [];                   %geometric dop (position + time)
est.numtx   = 0;                    %number of used channels

return;
%=========================================================
%=========================================================