% 提取北斗与伽利略卫星参数
clear,clc
navdata=struct('prn',nan,'year',nan,'month',nan,'day',nan,'hour',nan,'min'...
,nan,'sec',nan,'a0',nan,'a1',nan,'a2',nan,'aode',NaN,'crs',NaN,'dn',NaN,...
'm0',NaN,'cuc',NaN,'e',NaN,'cus',NaN,'a',NaN,'toe',...
NaN,'cic',NaN,'om0',NaN,'cis',NaN,'i0',NaN,'crc',NaN,'w',NaN,...
'dom',NaN,'di', NaN,'cflg12',NaN,'weekno',NaN,'pflg12',NaN,...
'svaccuracy',NaN,'svhealth',NaN,'tgd',NaN,'aodc',NaN,'transmission',...
NaN,'s1',NaN,'s2',NaN,'s3',NaN);
fid = fopen('brdm0660.16p');
k=1;
position=[];
bdsagal=[];
format long e
while 1
line = fgetl(fid);
answer =findstr(line,'END OF HEADER');
if ~isempty(answer)
break;
end
end
while 1
line = fgetl(fid);
if ~isempty( findstr(line,'E11'))
navdata(k).prn = str2num(line(2:4));
navdata(k).year= str2num(line(5:9));
navdata(k).month = str2num(line(10:12));
navdata(k).day = str2num(line(13:15));
navdata(k).hour = str2num(line(16:18));
navdata(k).min = str2num(line(19:21));
navdata(k).sec = str2num(line(22:23));
navdata(k).a0 = str2num(line(24:42));
navdata(k).a1 = str2num(line(44:61));
navdata(k).a2 = str2num(line(62:80));
line = fgetl(fid); % second line
navdata(k).aode = str2num(line(5:23));
navdata(k).crs = str2num(line(24:42));
navdata(k).dn = str2num(line(43:61));
navdata(k).m0 = str2num(line(62:80));
line = fgetl(fid);
navdata(k).cuc = str2num(line(5:23));
navdata(k).e = str2num(line(24:42));
navdata(k).cus = str2num(line(43:61));
navdata(k).a = str2num(line(62:80))
line = fgetl(fid);
navdata(k).toe = str2num(line(5:23));
navdata(k).cic = str2num(line(24:42));
navdata(k).om0 = str2num(line(43:61));
navdata(k).cis = str2num(line(62:80));
line = fgetl(fid);
navdata(k).i0 = str2num(line(5:23));
navdata(k).crc = str2num(line(24:42));
navdata(k).w = str2num(line(43:61));
navdata(k).dom = str2num(line(62:80));
line = fgetl(fid);
navdata(k).di = str2num(line(5:23));
navdata(k).cflg12 = str2num(line(24:42));
navdata(k).weekno = str2num(line(43:61));
navdata(k).pflg12 = str2num(line(62:80));
line = fgetl(fid);
navdata(k).svaccuracy = str2num(line(5:23));
navdata(k).svhealth= str2num(line(24:42));
navdata(k).tgd = str2num(line(43:61));
navdata(k).aodc = str2num(line(62:80));
line = fgetl(fid);
navdata(k).transmission = str2num(line(5:23));
navdata(k).s1 = str2num(line(24:42));
navdata(k).s2 = str2num(line(43:61));
navdata(k).s3 = str2num(line(62:80));
if navdata(k).min==0
position=gpsposition( navdata(k).year,navdata(k).month,navdata(k).day,navdata(k).hour,navdata(k).min,navdata(k).sec,navdata(k).a0,navdata(k).a1,navdata(k).a2,navdata(k).crs,navdata(k).dn,navdata(k).m0,navdata(k).cuc,navdata(k).e,navdata(k).cus, navdata(k).a,navdata(k).toe,navdata(k).cic,navdata(k).om0,navdata(k).cis,navdata(k).i0,navdata(k).crc,navdata(k).w,navdata(k).dom,navdata(k).di);
bdsagal(k,1)=position(1);
bdsagal(k,2)=position(2);
bdsagal(k,3)=position(3);
k=k+1;
end
elseif ~isempty( findstr(line,'C01'))
navdata(k).prn = str2num(line(2:4));
navdata(k).year= str2num(line(5:9));
navdata(k).month = str2num(line(10:12));
navdata(k).day = str2num(line(13:15));
navdata(k).hour = str2num(line(16:18));
navdata(k).min = str2num(line(19:21));
navdata(k).sec = str2num(line(22:23));
navdata(k).a0 = str2num(line(24:42));
navdata(k).a1 = str2num(line(43:61));
navdata(k).a2 = str2num(line(62:80));
line = fgetl(fid); % second line
navdata(k).aode = str2num(line(5:23));
navdata(k).crs = str2num(line(24:42));
navdata(k).dn = str2num(line(43:61));
navdata(k).m0 = str2num(line(62:80))
line = fgetl(fid);
navdata(k).cuc = str2num(line(5:23));
navdata(k).e = str2num(line(24:42));
navdata(k).cus = str2num(line(43:61));
navdata(k).a = str2num(line(62:80))
line = fgetl(fid);
navdata(k).toe = str2num(line(5:23));
navdata(k).cic = str2num(line(24:42));
navdata(k).om0 = str2num(line(43:61));
navdata(k).cis = str2num(line(62:80));
line = fgetl(fid);
navdata(k).i0 = str2num(line(5:23));
navdata(k).crc = str2num(line(24:42));
navdata(k).w = str2num(line(43:61));
navdata(k).dom = str2num(line(62:80));
line = fgetl(fid);
navdata(k).di = str2num(line(5:23));
navdata(k).cflg12 = str2num(line(24:42));
navdata(k).weekno = str2num(line(43:61));
navdata(k).pflg12 = str2num(line(62:80));
line = fgetl(fid);
navdata(k).svaccuracy = str2num(line(5:23));
navdata(k).svhealth= str2num(line(24:42));
navdata(k).tgd = str2num(line(43:61));
navdata(k).aodc = str2num(line(62:80));
line = fgetl(fid);
navdata(k).transmission = str2num(line(5:23));
navdata(k).s1 = str2num(line(24:42));
navdata(k).s2 = str2num(line(43:61));
navdata(k).s3 = str2num(line(62:80));
position=bdsposition( navdata(k).year,navdata(k).month,navdata(k).day,navdata(k).hour,navdata(k).min,navdata(k).sec,navdata(k).a0,navdata(k).a1,navdata(k).a2,navdata(k).crs,navdata(k).dn,navdata(k).m0,navdata(k).cuc,navdata(k).e,navdata(k).cus, navdata(k).a,navdata(k).toe,navdata(k).cic,navdata(k).om0,navdata(k).cis,navdata(k).i0,navdata(k).crc,navdata(k).w,navdata(k).dom,navdata(k).di);
bdsagal(k,1)=position(1);
bdsagal(k,2)=position(2);
bdsagal(k,3)=position(3);
k=k+1;
elseif ~isempty( findstr(line,'C06'))
navdata(k).prn = str2num(line(2:4));
navdata(k).year= str2num(line(5:9));
navdata(k).month = str2num(line(10:12));
navdata(k).day = str2num(line(13:15));
navdata(k).hour = str2num(line(16:18));
navdata(k).min = str2num(line(19:21));
navdata(k).sec = str2num(line(22:23));
navdata(k).a0 = str2num(line(24:42));
navdata(k).a1 = str2num(line(43:61));
navdata(k).a2 = str2num(line(62:80));
line = fgetl(fid); % second line
navdata(k).aode = str2num(line(5:23));
navdata(k).crs = str2num(line(24:42));
navdata(k).dn = str2num(line(43:61));
navdata(k).m0 = str2num(line(62:80));
line = fgetl(fid);
navdata(k).cuc = str2num(line(5:23));
navdata(k).e = str2num(line(24:42));
navdata(k).cus = str2num(line(43:61));
navdata(k).a = str2num(line(62:80));
line = fgetl(fid);
navdata(k).toe = str2num(line(5:23));
navdata(k).cic = str2num(line(24:42));
navdata(k).om0 = str2num(line(43:61));
navdata(k).cis = str2num(line(62:80));
line = fgetl(fid);
navdata(k).i0 = str2num(line(5:23));
navdata(k).crc = str2num(line(24:42));
navdata(k).w = str2num(line(43:61));
navdata(k).dom = str2num(line(62:80));
line = fgetl(fid);
navdata(k).di = str2num(line(5:23));
navdata(k).cflg12 = str2num(line(24:42));
navdata(k).weekno = str2num(line(43:61));
navdata(k).pflg12 = str2num(line(62:80));
line = fgetl(fid);
navdata(k).svaccuracy = str2num(line(5:23));
navdata(k).svhealth= str2num(line(24:42));
navdata(k).tgd = str2num(line(43:61));
navdata(k).aodc = str2num(line(62:80));
line = fgetl(fid);
navdata(k).transmission = str2num(line(5:23));
navdata(k).s1 = str2num(line(24:42));
navdata(k).s2 = str2num(line(43:61));
navdata(k).s3 = str2num(line(62:80));
position=bdsposition1( navdata(k).year,navdata(k).month,navdata(k).day,navdata(k).hour,navdata(k).min,navdata(k).sec,navdata(k).a0,navdata(k).a1,navdata(k).a2,navdata(k).crs,navdata(k).dn,navdata(k).m0,navdata(k).cuc,navdata(k).e,navdata(k).cus, navdata(k).a,navdata(k).toe,navdata(k).cic,navdata(k).om0,navdata(k).cis,navdata(k).i0,navdata(k).crc,navdata(k).w,navdata(k).dom,navdata(k).di);
bdsagal(k,1)=position(1);
bdsagal(k,2)=position(2);
bdsagal(k,3)=position(3);
k=k+1;
elseif ~isempty( findstr(line,'C11'))
navdata(k).prn = str2num(line(2:4));
navdata(k).year= str2num(line(5:9));
navdata(k).month = str2num(line(10:12));
navdata(k).day = str2num(line(13:15));
navdata(k).hour = str2num(line(16:18));
navdata(k).min = str2num(line(19:21));
navdata(k).sec = str2num(line(22:23));
navdata(k).a0 = str2num(line(24:42));
navdata(k).a1 = str2num(line(43:61));
navdata(k).a2 = str2num(line(62:80));
line = fgetl(fid); % second line
navdata(k).aode = str2num(line(5:23));
navdata(k).crs = str2num(line(24:42));
navdata(k).dn = str2num(line(43:61));
navdata(k
评论5