%% Estimate Receiver Position from Pseudoranges and Satellite Positions
% Use the receiverposition function to estimate a GNSS receiver position. Get the satellte positiions and velocities using the gnssconstellation function. Generate pseudoranges from these positions using the pseudoranges function.
% Specify a receiver position in geodetic coordinates (latitude, longitude, altitude) and a receiver velocity in the local navigation frame.

recPos = [42 -71 50];
recVel = [1 2 3];

% Get the satellite positions for the current time.

t = datetime('now');
[gpsSatPos,gpsSatVel] = gnssconstellation(t);

% Get the the pseudoranges and pseudorange rates between the GNSS receiver and the satellites.

[p,pdot] = pseudoranges(recPos,gpsSatPos,recVel,gpsSatVel);

% Use the pseudoranges to estimate the receiver position and velocity. The values close to your original receiver position and velocity used to generate the satellite position and pseudoranges.

[lla,gnssVel] = receiverposition(p,gpsSatPos,pdot,gpsSatVel)

% Copyright 2020 The MathWorks, Inc.