Home > other >  Matlab for reading data
Matlab for reading data

Time:11-05

% put each variables in the formula in the matrix of 1 x 417, change the variables in the formula of generation to use matrix and the matrix, thus avoiding the loop variable problem, directly out of 417 kinds of data, weakness is trouble
The function of Orbit=readrinexG1 (File, varargin)
If the size (varargin, 2)==1; Prn=varargin {1}; The else Prn=1:36; End

Orbit. Prn=[]; % Prn number
Orbit. Coord=[]; % Cartesian coordinates, metres
Orbit. Time=[]; % Times of coordinates, datenums
Orbit. Clock=[]; % Satellite clock errors, microsec
Orbit. Sat=[];
Orbit=repmat (Orbit, 1, length (Prn));

PI=3.1415926;
GM=3.986005 * 10 ^ 14;
For k=1: size (File, 1)
If exist (the File (k, :), 'File') % if the first k line is the value of "type is a File"
X=textread (the File '% s',' delimiter ', '\ n');
X=strvcat (x {});
Izero=find (x (1: end, 1)=="G");
I=izero (4: end, 1);
Time=datenum (str2num (x (I, 5:23)));
The Sat=str2num (x (I, 2));
Shu=numel (I);
% to build a 598 lines, each column element is GM's matrix
A=ones (shu, 1);
A (a==1)=GM;
% read line 1
Year=str2num (x (I, 8));
The month=str2num (x (I, 10:11));
Day=str2num (x (I, 11));
Hour=str2num (x (I, 16:17));
Min=str2num (x (I, the word));
The SEC=str2num (x (I, makest));
% of satellite clock bias s, s/s drift, drift velocity s/s ^ (2)
Af0=str2num (x (I, 24:42 "));
%)Af1=str2num (x (I, dealt 1));
%)Af2=str2num (x (I, 62:80));
%)% read line 2
% ephemeris IODE release time, Crs (m), O_n (rad/s), M0 (rad)
IODE=str2num (x (I + 1, 1:18));
%)Crs=str2num (x (I + 1) : 37));
%)O_n=str2num (x (I + 1, 38:56));
%)M0=str2num (x (I + 1,57:80));
%)% extract data given above
% read line 3
% of the satellite Cuc (rad), orbital eccentricity e, Cus (radions), Sqrt (A) prescribing (m)
Cuc=str2num (x (I + 2, 1:19));
%)E=str2num (x (I + 2, 20:38));
%)Cus=str2num (x (I + 2 33:6 57));
%)Sqrt_A=str2num (x (I + 2, 58:80));
%)% extract data given above
% read line 4
% TOE ephemeris reference point TOE, Cic (rad), Omega0 (rad), Cis (rad)
Toe=str2num (x (I + 3, 1:18));
%)Cic=str2num (x (I + 3) : 37));
%)Omega0=str2num (x (I + 3:56));
%)Cis=str2num (x (I + 3,57:80));
%)
% read line 5% reference time ascending node red diameter i_0 (rad), Crc (m), w (rad), Omega (rad)
I_0=str2num (x (I + 4, 1:19));
%)Crc=str2num (x (I + 4, 20:37));
%)W=str2num (x (I + 4, 38:56));
%)Omega=str2num (x (I + 4,57:80));
%)% extract data given above
% read line 6
% orbital inclination rate IDOT I (rad/s), code cflgL2 on L2, PS weeks weekno, L2 - P code data tag pflgL2
IDOT_i=str2num (x (I + 5, 1:19));
%)% cflgL2=str2num (x (I + 5, 20:37));
Weekno=str2num (x (I + 5 33:6 57));
%)% extract data given above
% read line 7
% Svac satellite precision (m), satellite health Svhlth, TGD (SEC), data (IODC clock
Svac=str2num (x (I + 6, 1:19));
%)Svhlth=str2num (x (I + 6, 20:37));
%)TGD=str2num (x (I + 6 33:6 57));
%)IDOC=str2num (x (I + 6, 58:80));
%)% extract data given above
% to read lines 8 this useless
Send time Transmist % cables, fitting range h.
% the Transmit (I)=str2num (line () ");

Calculation of satellite coordinates % % % % % %
% satellite average angular velocity n
(n=SQRT (a)/(Sqrt_A. ^ 3)) + O_n;
%)% calculation of the instantaneous satellite flat anomaly M
Ut=hour + (min/60) + (SEC/3600); % to civil day when minutes into real %)
% if month<=2
Year=year - % 1;
% the month=month + 12;
% the else
% year=year;
The month %=month;
% end
% if the month (I) & lt;=2
% during (I)=y (I) - 1;
(I)=month % m (I) + 12;
% the else
% during (I)=y (I);
% m (I)=month (I);
% end
Jd=fix (365.25 * year) + fix (30.6001 x + 1) (month) + day + (ut/24) + 1720981.5; % to civil day is (date) (month) (year) conversion ChengRu slightly
%)% weekgps (I)=int ((jd) (I) 2444244.5/7);
Weeksec=(jd - 2444244.5 - weekno * 7) * 24 * 3600;
%)Tk=weeksec - toe; %???????
Deltat=af0 + af1. * tk + af2. * tk. ^ 2; %??????
Tk=tk + deltat; %???????

SDF=find (tk> 302400);
%)Tk (SDF, :)=tk (SDF) - 604800;
%)Sdf1=find (tk<- 302400);
%)Tk (sdf1, :)=tk (sdf1, :) + 604800;
%)M=M0 + n. * tk;
%)% % calculating eccentric anomaly
E_temp=M;
%)D_E=1;
%)While (abs (d_E) & lt; 1-15) % e???????
E_temp_next=M + e * sin (E_temp); %???????
D_E=E_temp_next - E_temp; %???????
E_temp=E_temp_next; %???????
End
E=E_temp;
V=atan2 (SQRT (1 - e. * e). * sin (e), cos (e) - (e));
%)
% to calculate l pay from u
U=V + w;

% calculation perturbation correction itemSigmaU=Cuc. * cos (2 * u) + Cus. * sin (2 * u);
SigmaR=Crc. * cos (2 * u) + Crs. * sin (2 * u);
SigmaI=Cic. * cos (2 * u) + Cis. * sin (2 * u);
% u, r, I, to perturbation correction
U=u + SigmaU;
A=(Sqrt_A). ^ 2;
R=a. * (1 - e. * cos (e)) + SigmaR;
I=i_0 + SigmaI + IDOT_i. * tk.
% to calculate the positions of the satellites in orbit coordinate system
X0=r. * cos (u);
Y0=r. * sin (u);
% y (1, 2)=x0;
% y (2, 2)=y0;
% calculation instant observation the longitude of ascending node L
We1=7.29211567 * 10 ^ (5); % the earth rotation angular velocity
We=ones (shu, 1);
We (we==1)=we1;
L=Omega0 + (Omega we). * tk - we. * toe;
% calculation of satellite position in instantaneous earth coordinate system
XYZ %=struct (I 'X', NaN, 'Y', NaN, 'Z', NaN);
X=x0. * cos (L) - y0. * cos (I). * sin (L);
Y=x0. * sin (L) + y0. * cos (I). * cos (L);
Z=y0. * sin (I);
Pos=[X Y Z];

For I=1: length (Prn)
Orbit (I). The Prn=Prn (I);
Orbit (I). Time=[Orbit (I). Time; Time (find (Sat==Prn (I)), :)];
Orbit (I). Coord=[Orbit (I) Coord; Pos (find (Sat==Prn (I)), :)];
% Orbit (I). Clock=[Orbit (I). The Clock; Clk (find (Sat==Prn (I)), :)];
Orbit (I). The Sat=[Orbit (I) the Sat and Sat (find (Sat==Prn (I)), :)];
End
The else fprintf (' Warning from ning: % s not found \ n ', the File (k, :)); End
End
% because when have time to repeat, so behind Coord data also have repeated, behind the program automatically remove duplicate number
% 20 data originally, so the results of 11, the remaining nine are repeated
For I=1: length (Orbit)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related