EE navigations system
GPS Project - Data and Functions/ECEF2ENU.m
function enu = ECEF2ENU(ece,orgece,orgllh) %ENU = ECEF2ENU(ECEF,orgECEF,orgLLH) % % EC2ENU: Convert ECEF coordinates to East-North-Up with % respect to orgECEF and orgLLH (orgECEF is the same % location as orgLLH, orgLLH in radians). % % VARIABLES: % % OU-ECE-AEC Oct. 1988 FvG % WJP2011: Vectorized. Now accepts ece as a 3x1, a 3xM, 3xMxN, etc matrix % Rotate the difference vector into ENU coordinates sla = sin(orgllh(1,1)); cla = cos(orgllh(1,1)); slo = sin(orgllh(2,1)); clo = cos(orgllh(2,1)); C = [ -slo clo 0 ; ... -sla*clo -sla*slo cla; ... cla*clo cla*slo sla]; if size(ece,2)==1 && ndims(ece)==2; %3x1 vector % enu = [ -slo clo 0 ; ... % -sla*clo -sla*slo cla; ... % cla*clo cla*slo sla] * difece; difece = ece - orgece; % difference between coordinate origins enu= C * difece; else %3xM or 3xMxN etc %Vectorized ECEF2ENU function: enu=NaN(size(ece)); %reshape ece to 3xN matrix %ece=reshape(ece,3,size(ece,2)*size(ece,3)*size(ece,4)); ece=reshape(ece,3,[]); difece=zeros(size(ece)); difece(1,:)=ece(1,:)-orgece(1); difece(2,:)=ece(2,:)-orgece(2); difece(3,:)=ece(3,:)-orgece(3); for i=1:3 enu(i,:)=C(i,1)*difece(1,:)+C(i,2)*difece(2,:)+C(i,3)*difece(3,:); end end
__MACOSX/GPS Project - Data and Functions/._ECEF2ENU.m
GPS Project - Data and Functions/ECEF2LLH.m
function wgs = ECEF2LLH(xyz) %wgs = ECEF2LLH(xyz) % % This function converts cartesian (x,y,z) coordinates of a reference % point in ECEF to lat, lon, height coordinates in the WGS 84 system % % VARIABLES: % wgs - 3 by 1 array containing position lat, lon, height % (rad, rad, m) % xyz - 3 by 1 array containing position as x,y,z % (m, m, m) % % a - semi-major axis % f - spheroidal flattening % esq - eccentricity squared % sp - sine of lattitude % cp - cosine of latitude % sl - sine of longitude % cl - cosine of longitude % gsq - intermediate temp variable % x - cartesian coordinte in feet % r - intermediate temp variable % % This function is based on one developed by the % National Geodetic Survey, Rockville, Maryland. % % WJP2010: Vectorized. Now accepts xyz as a 3x1, a 3xM, 3xMxN, or a 3xMxNxO matrix wgs=zeros(size(xyz)); f=1/298.257223563; esq=f*(2-f); a=6378137; x = xyz(1,:,:,:); y = xyz(2,:,:,:); z = xyz(3,:,:,:); rsq = (x.*x) + (y.*y); h = esq.*z; for i = 1:6; zp = z + h; r = sqrt(rsq + (zp.*zp)); sp = zp./r; gsq = 1.0 - (esq.*sp.*sp); en = a./sqrt(gsq); p = en.*esq.*sp; %if abs(h-p) < 0.0005,break,end h = p; end; p = atan2(zp,sqrt(rsq)); h = r - en; wgs(2,:,:,:) = atan2(y, x);%*180/pi; wgs(1,:,:,:) = p;%*180/pi; wgs(3,:,:,:) = h; % wgs=zeros(3,1); % f=1/298.257223563; % esq=f*(2-f); % a=6378137; % x = xyz(1); % y = xyz(2); % z = xyz(3); % rsq = (x*x) + (y*y); % h = esq*z; % for i = 1:6; % zp = z + h; % r = sqrt(rsq + (zp*zp)); % sp = zp/r; % gsq = 1.0 - (esq*sp*sp); % en = a/sqrt(gsq); % p = en*esq*sp; % if abs(h-p) < 0.0005,break,end % h = p; % end; % p = atan2(zp,sqrt(rsq)); % h = r - en; % wgs(2) = atan2(y, x);%*180/pi; % wgs(1) = p;%*180/pi; % wgs(3) = h;
GPS Project - Data and Functions/EE4853-5853_GPS_PR.mat
L1PSR:[9x1 double array]
L2PSR:[9x1 double array]
PRNs:[1x9 double array]
SatPPP:[1x1 struct array]
- [3x9 double array]
- [9x1 double array]
SatBC:[1x1 struct array]
- [3x9 double array]
- [9x1 double array]
TruthLLH:[3x1 double array]
GPS Project - Data and Functions/ENU2ECEF.m
function ecef = ENU2ECEF(enu,orgece,orgllh) % ecef = ENU2ECEF(enu,orgece,orgllh) % % ENU2EC: Convert ENU coordinates to ECEF with respect to % the origin (orgece is the same location as orgllh). % % OU-ECE-AEC Oct. 1988 FvG sla = sin(orgllh(1)); cla = cos(orgllh(1)); slo = sin(orgllh(2)); clo = cos(orgllh(2)); ROT = [-slo clo 0; -sla*clo -sla*slo cla; cla*clo cla*slo sla]; difece = inv(ROT) * enu; % add the difference between the enu and ecef origins ecef = orgece + difece;
GPS Project - Data and Functions/LLH2ECEF.m
function ecef = LLH2ECEF(llh) % % LLH2EC: Convert lat/lon/height coordinates to Earth-Centered % Earth-Fixed (ECEF) coordinates (WGS72). % % Input: llh = lat,long,height location (rad,rad,user units) % Output: ecef = x,y,z (user units) % % OU-ECE-AEC Oct. 1988 FvG % WJP2010: Vectorized. Now accepts llh as a 3x1, a 3xM, 3xMxN, or a 3xMxNxO matrix %A = 6378135.0; % Earth's radius (m), old number from 1997 A = 6378137.0; % Earth's radius (m) per WGS84, CB %E = 8.181881066e-02; % Eccentricity, old number from 1997 E = 8.18191908e-2; % Eccentricity per WGS84, CB ESQ = E * E; % ecef=zeros(3,1); % % SP = sin(llh(1)); % CP = cos(llh(1)); % SL = sin(llh(2)); % CL = cos(llh(2)); % GSQ = 1.0 - (ESQ*SP*SP); % EN = A / sqrt(GSQ); % Z = (EN + llh(3)) * CP; % ecef(1) = Z * CL; % ecef(2) = Z * SL; % EN = EN - (ESQ * EN); % ecef(3) = (EN + llh(3)) * SP; ecef=zeros(size(llh)); SP = sin(llh(1,:,:,:)); CP = cos(llh(1,:,:,:)); SL = sin(llh(2,:,:,:)); CL = cos(llh(2,:,:,:)); GSQ = 1.0 - (ESQ.*SP.*SP); EN = A ./ sqrt(GSQ); Z = (EN + llh(3,:,:,:)) .* CP; ecef(1,:,:,:) = Z .* CL; ecef(2,:,:,:) = Z .* SL; EN = EN - (ESQ .* EN); ecef(3,:,:,:) = (EN + llh(3,:,:,:)) .* SP;