• 大小: 8KB
    文件类型: .m
    金币: 1
    下载: 0 次
    发布日期: 2021-06-16
  • 语言: Matlab
  • 标签: GPS/北斗  

资源简介

GPS/北斗的O文件读取程序 matlab版 读取rinex3.0格式的

资源截图

代码片段和文件信息

function [ofile] = ReadOfile_3
% 读取rinex O文件中的信息 version 3.02
% 包括各观测值以及其文件头的内容
%%
%读取文件头
[filenamefilepath] = uigetfile(‘*.**O‘‘选择观测文件‘);
fileName = strcat(filepathfilename);
fid = fopen(fileName‘r+‘);

while 1 
    tline = fgetl(fid);
    if ~ischar(tline)
        break;
    end
    
    if ~isempty(regexp(tline ‘ +$‘ ‘end‘))
        temp = regexp(tline ‘ +$‘‘end‘);
        for ii = temp:-1:1
            if strcmp(tline(ii) ‘ ‘)~=1
                break;
            end
        end
        tline = tline(1:ii);
    end
    
    str = char(regexp(tline‘RINEX VERSION / TYPE‘ ‘match‘));
    if strcmp(str‘RINEX VERSION / TYPE‘)
        ofile.rnx_vrn = str2double(tline(6:8));
        ofile.rnx_type = tline(40:41);
    end
    
    str = char(regexp(tline‘PGM / RUN BY / DATE‘‘match‘));
    if strcmp(str ‘PGM / RUN BY / DATE‘)
        ofile.pgm = tline(1:15);
        ofile.company = tline(21:40);
        ofile.ob_date = tline(41:59);
    end
    
    str = char(regexp(tline‘COMMENT‘‘match‘));
    if strcmp(str‘COMMENT‘)
        continue;
    end
    
    str = char(regexp(tline‘MARKER NAME‘‘match‘));
    if strcmp(str‘MARKER NAME‘)
        ofile.mark_name = tline(1:10);
    end
    
    str = char(regexp(tline‘MARKER NUMBER‘‘match‘));
    if strcmp(str‘MARKER NUMBER‘)
        ofile.mark_number = tline(1:10);
    end
    
    str = char(regexp(tline‘APPROX POSITION XYZ‘‘match‘));
    if strcmp(str‘APPROX POSITION XYZ‘)
        ofile.app_pos(11) = str2double(tline(1:14));
        ofile.app_pos(21) = str2double(tline(16:28));
        ofile.app_pos(31) = str2double(tline(30:42));
    end
    
    str = char(regexp(tline‘ANTENNA: DELTA H/E/N‘‘match‘));
    if strcmp(str‘ANTENNA: DELTA H/E/N‘)
        ofile.ant_HEN.H = str2double(tline(1:14));
        ofile.ant_HEN.E = str2double(tline(21:29));
        ofile.ant_HEN.N = str2double(tline(36:42));
    end
    
    str = char(regexp(tline‘SYS / # / OBS TYPES‘‘match‘));
    if strcmp(str‘SYS / # / OBS TYPES‘)
        if tline(1) == ‘G‘
            ofile.obs_GPS_typecount = str2double(tline(5:6));
            ofile.obs_GPS_type = [];
            for ii = 1:ofile.obs_GPS_typecount
                ofile.obs_GPS_type = [ofile.obs_GPS_type tline(4*(ii-1)+8:4*(ii-1)+10)];
            end
        elseif tline(1) == ‘C‘
            ofile.obs_BDS_typecount=str2double(tline(5:6));
            ofile.obs_BDS_type = [];
            for ii = 1:ofile.obs_BDS_typecount
                ofile.obs_BDS_type = [ofile.obs_BDS_type tline(4*(ii-1)+8:4*(ii-1)+10)];
            end
%         elseif tline(1) == ‘R‘
%             O_header.obs_GLO_typecount=str2double(tline(6:7));
%             O_header.obs_GLO_type = [];
%             for ii = 1:O_header.obs_GLO_typecount
%                 O_header.obs_GLO_type = [O_header.obs_GLO_type tline(4*(ii-1)+9:4*(ii-1)+11)];
%             end
        end
    end
    
    st

评论

共有 条评论

相关资源