function [result] = posfixSGMP(filename);
%---------------------------------------------------------
% Calculate position and clk bias using pr and eph
% By Juyong Do,  Jan 15, 2009
%---------------------------------------------------------
% input  : data file (SGMP format)
% output : position estimation results
%=========================================================
%=========================================================
% filename = 'Ktz_GPak_2d81_1515_00_0';
paraPosfixSGMP;     %program parameters
initPosfixSGMP;     %initialize variables
% clc, close all, result=[]; result.numepoch = 1e3;

%=========================================================
%Calculate satellite, user position and clk bias
for i=1:result.numepoch     
    %get current epoch data
    [meas, aiding, est] = getDataSGMP(rx.meas(i), rx.aiding, est);
    
    %calculate GPS Pseudorange, Tx Position, Weighting, Elevation
    [gpsmeas          ] = calGPSSGMP(meas, aiding, est);

    %calculate user position and clk bias based on processed GPS measurements
    [est              ] = calUsrSGMP(gpsmeas, est);    
    
    %update results
    [result.est(i), est]= updateResultSGMP(est);
end

%=========================================================
% Calculate statistics and plot user position in ENU
result  = plotResultSGMP(rx, result, filename);

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