⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readgpsdata.m

📁 包含三个M文件
💻 M
字号:
function EphDat=ReadGpsData
global EphDat
EphDat=struct;
[filename,pathname]=uigetfile('*.**N','读取GPS广播星历文件');
fid1=fopen(strcat(pathname,filename),'rt');
if(fid1==-1)
    msgbox('Input File or Path is not correct','warning ','warn');
    break;
end
while(1)
    temp=fgets(fid1);
    header=findstr(temp,'END OF HEADER ');
    if(~isempty(header))
        break;
    end
end
i=1;
while(1)
        temp=fgets(fid1);
        if(temp==-1)
            break;
        end
        EphDat(i).PRN=str2num(temp(1:2));
        year=str2num(temp(4:5));
        EphDat(i).toc=TimetoJD(year,str2num(temp(7:8)),str2num(temp(10:11)),str2num(temp(13:14)),str2num(temp(16:17)),str2num(temp(19:22)));
        EphDat(i).a0=str2num(temp(23:41)); 
        EphDat(i).a1=str2num(temp(42:60));
        EphDat(i).a2=str2num(temp(61:79));
    temp=fgets(fid1);
        EphDat(i).idoe=str2num(temp(4:22));
        EphDat(i).Crs=str2num(temp(23:41));
        EphDat(i).dn=str2num(temp(42:60));
        EphDat(i).M0=str2num(temp(61:79));
    temp=fgets(fid1);
        EphDat(i).Cuc=str2num(temp(4:22));
        EphDat(i).e=str2num(temp(23:41));
        EphDat(i).Cus=str2num(temp(42:60));
        EphDat(i).sqa=str2num(temp(61:79));
    temp=fgets(fid1);
        EphDat(i).toe=str2num(temp(4:22));
        EphDat(i).Cic=str2num(temp(23:41));
        EphDat(i).omg0=str2num(temp(42:60));
        EphDat(i).Cis=str2num(temp(61:79));
    temp=fgets(fid1);
        EphDat(i).i0=str2num(temp(4:22));
        EphDat(i).Crc=str2num(temp(23:41));
        EphDat(i).w=str2num(temp(42:60));
        EphDat(i).omg=str2num(temp(61:79));
    temp=fgets(fid1);
        EphDat(i).iDot=str2num(temp(4:22));
        EphDat(i).cflgl2=str2num(temp(23:41));
        EphDat(i).weekno=str2num(temp(42:60));
        EphDat(i).pflgl2=str2num(temp(61:79));
    temp=fgets(fid1);
        EphDat(i).svacc=str2num(temp(4:22));
        EphDat(i).svhlth=str2num(temp(23:41));
        EphDat(i).tgd=str2num(temp(42:60));
        EphDat(i).aodc=str2num(temp(61:79));
    temp=fgets(fid1);
        EphDat(i).ttm=str2num(temp(4:22));
    if(i~=1)                 %删除重复数据
         for k= i-1:i
             if (EphDat(i-1).PRN~=EphDat(i).PRN)
                 break;
             elseif abs(EphDat(i-1).toc-EphDat(i).toc)<0.001
                  i=i - 1;
             end
          end
     end
    i=i + 1;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -