function [ SP3 ] = read_SP3( )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
format long;
[filename, pathname, filterindex] = uigetfile( {'*.*sp3','DATA-files (*.sp3)';'*.*', 'All Files (*.*)'}, '选择精密星历数据文件(sp3文件)');
if filterindex==0
return
else
file = fullfile(pathname,filename);
end
fid = fopen(file); %%%fopen(file)表示打开文件名为file的文件
if fid<=0 %%%文件打开成功返回大于0的数
errordlg('文件打开错误','Open File Error')
else
tline=fgetl(fid); %开始读取文件的第一行 如 tline= "2.10 OBSERVATION DATA G (GPS) RINEX VERSION / TYPE"
end
tline=strrep(tline,'#cP',' ');%%%去掉前面的#cP
[s,tline] = strtok(tline);s1 = strcat(s,'/');%%%%%读取年份
[s,tline] = strtok(tline);s1 = strcat(s1,s,'/');
[s,tline] = strtok(tline);s1 = strcat(s1,s);
SP3.date=s1; %%%为该精密星历的日期赋值
for i=1:21 %%%跳过中间无用的行
tline=fgetl(fid);
end
numEpoch=0;%用来记录历元个数
flagReadData=1;
tline=fgetl(fid);
while flagReadData==1
tline=strrep(tline,'*',' ');%%%去掉前面的#cP
[s,tline] = strtok(tline); iYear = str2num(s); s1 = strcat(s,'/');
[s,tline] = strtok(tline); iMonth = str2num(s); s1 = strcat(s1,s,'/');
[s,tline] = strtok(tline); iDay = str2num(s); s1 = strcat(s1,s,'/');
[s,tline] = strtok(tline); iHour = str2num(s); s1 = strcat(s1,s,':');
[s,tline] = strtok(tline); iMin = str2num(s); s1 = strcat(s1,s,':');
[s,tline] = strtok(tline); fSecond = str2num(s); s1 = strcat(s1,s);
[weekno,weeksec] =TimeConvertWeekTime(iYear,iMonth,iDay,iHour,iMin,fSecond);%%%%%%%%%%%给出年月日,时分秒,求GPS周,GPS秒等
SP3.liyuan(numEpoch+1).GPSweekno = weekno;
SP3.liyuan(numEpoch+1).GPSweeksec = weeksec;
SP3.liyuan(numEpoch+1).GPSymd = s1;
for j=1:32 %%%读取32颗卫星的数据
tline=fgetl(fid);
[s,tline] = strtok(tline);
[s,tline] = strtok(tline);data=1000*str2num(s); SP3.liyuan(numEpoch+1).prn(j).data(1,1)=data;
[s,tline] = strtok(tline);data=1000*str2num(s); SP3.liyuan(numEpoch+1).prn(j).data(1,2)=data;
[s,tline] = strtok(tline);data=1000*str2num(s); SP3.liyuan(numEpoch+1).prn(j).data(1,3)=data;
end
tline=fgetl(fid);
if length(tline)<10
flagReadData=0;%%%%说明数据读完
else
numEpoch=numEpoch+1;
end
end
end
- 1
- 2
前往页