function [OBSER]=ReadObsData()
clear;
jsq1=0;
jsq2=0;
jsq3=0;
jsq4=0;
[filename,pathname,filterindex]=uigetfile('*.18o','选择一个O文件');%文件、路径、索引,ui为图形界面
filepathname=[pathname,filename];
outfid = fopen(filepathname,'rt');%filepathname为具体的地址,rt是读的权限
%outfid是该文件的标识符,每次打开文件时都会分配一个数字
if outfid == -1
ans='打开文件失败!'
return;
else
while ~feof(outfid) %如果标记不是文件结尾
jsq1=jsq1+1;
outnextline = fgetl(outfid); %字符数组,文件读取一行
strcell= regexp(outnextline,' ','split');%在‘ ’内的标识处打断
f=cellfun(@isempty,strcell) %清除cell内的空白数据
strcell=strcell(~f);
[r,c]=size(strcell);
laststr=strcell(1,c);
if strcmp(laststr,'NAME')==1 %点名
makername=strcell(1,1);
for a=1:25993
OBSER{a,1}=makername;
end
end
if strcmp(laststr,'XYZ')==1 %测站近似坐标
X0=strcell{1,1};
Y0=strcell{1,2};
Z0=strcell{1,3};
for a=1:25993
OBSER{a,6}=str2num(X0);
OBSER{a,7}=str2num(Y0);
OBSER{a,8}=str2num(Z0);
end
end
if strcmp(laststr,'OBSERV')==1 %观测类型数量
typesofobs=strcell(1,1);
for b=1:25993
OBSER{b,4}=typesofobs;
end
end
if strcmp(laststr,'HEADER')==1
break;
end
end %以上部分读文件头
while ~feof(outfid)
outnextline = fgetl(outfid);
strcell= regexp(outnextline,' ','split');
f=cellfun(@isempty,strcell)
strcell=strcell(~f);
[r,c]=size(strcell);
if c==8
jsq2=jsq2+1;
year=str2num(strcell{1,1});
year=2018;
month=str2num(strcell{1,2});
day=str2num(strcell{1,3});
hour=str2num(strcell{1,4});
minute=str2num(strcell{1,5});
second=str2num(strcell{1,6});
[gpstime,weekno]=GetGPSTime(year,month,day,hour,minute,second);
[r,c]=size(strcell);
starstr=strcell{1,c};
starlist= regexp(starstr,'G','split');%在G处打断
starnum=str2num(starlist{1,1}); %卫星总颗数
% for j=2:(starnum+1)
% jsq3=jsq3+1;
% stindex=starlist{1,j}; %卫星编号
% OBSER{jsq3,3}=stindex;
% end
for i=1:starnum
outnextline = fgetl(outfid);
strcell= regexp(outnextline,' ','split');
f=cellfun(@isempty,strcell)
strcell=strcell(~f);
[r,c]=size(strcell);
if c>2 && c<5
% jsq4=jsq4+1;
% OBSER{jsq4,2}=gpstime;
% P1=strcell{1,1};
% OBSER{jsq4,5}=str2num(P1);
% stindex=starlist{1,i}; %卫星编号
% OBSER{jsq4,3}=stindex;
outnextline = fgetl(outfid);
continue; %读取的是P1 一行有三个的情况没有p1数据,跳出不读
end
if c==5
jsq4=jsq4+1;
OBSER{jsq4,2}=gpstime;
P1=strcell{1,3}; %P1伪距
OBSER{jsq4,5}=str2num(P1);
stindex=starlist{1,i+1}; %卫星编号
OBSER{jsq4,3}=stindex;
end
outnextline = fgetl(outfid);
end
end
end %以上部分为读文件的数据部分
end
msgbox '观测数据导入完毕';
end
MATLAB GNSS单点定位程序
5星 · 超过95%的资源 需积分: 46 46 浏览量
2022-04-02
14:50:35
上传
评论 14
收藏 1.3MB ZIP 举报
爱捣蛋的小胖
- 粉丝: 0
- 资源: 5
最新资源
- 论文(最终)_20240430235101.pdf
- 基于python编写的Keras深度学习框架开发,利用卷积神经网络CNN,快速识别图片并进行分类
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论5