1. 绘制天空视图源码(Matlab)
clear;clc;
close all
filename='AZEL_Fly.txt';
fid = fopen(filename, 'r');
ts=0;
az=zeros(1,211);el=zeros(1,211);ns=zeros(1,211);time=zeros(1,1);
% read file
while(1)
line=fgetl(fid);
if (line == -1)
break;
end
if(line(1:1)=='>')
fprintf('%s\n',line);
yr=str2double(line(3:6));mon=str2double(line(8:9));day=str2double(line(11:12));
hr=str2double(line(14:15));min=str2double(line(17:18));sec=str2double(line(20:26));
vnum=str2double(line(27:30));t=day*24*3600+hr*3600+min*60+sec;
if(ts==0)
ts=t;
end
else
if(line(1:1)=='C')
prn_s=95;
elseif(line(1:1)=='G')
prn_s=0;
elseif(line(1:1)=='R')
prn_s=32;
end
sat=prn_s+str2double(line(2:3));ns((t-ts)+1,sat)=vnum;time((t-ts)+1,1)=hr+min/60+sec/3600;
az((t-ts)+1,sat)=str2double(line(4:12));el((t-ts)+1,sat)=str2double(line(13:21));
end
end
satn=1;pos=1;% pos->文字注记位置,pos=1->代表注记内容在卫星第一次出现的位置
% 遍历各卫星(按列存储各卫星高度角、方位角信息) GPS->[1-32],BDS->[96-158]
for i=1:211
ind=find(abs(az(:,i))>0);%非空信息列ind
if ~isempty(ind)
[row,col]=size(ind);
rho = rad2deg(el(ind,i));% 极径=90度-高度角(deg)
theta =az(ind,i); % 极角=方位角(rad)
polarplot(theta, rho, '.','MarkerSize',3);
% pos=fix(median([1:row]));% 文字标注在轨迹中间
leg{satn}=num2str(i-95,'C%02d');satn=satn+1;
text(theta(pos), rho(pos), num2str(i-95,'C%02d'), 'HorizontalAlignment',...
'center', 'VerticalAlignment', 'middle','FontName','Times New Roman');
hold on
end
end
rlim([0,90]); % 设置极径范围(0到90度)
thetaticks([0:30:360])
ax=gca;
ax.ThetaZeroLocation = 'top';
ax.RTick=[0,15,30,45,60,75,90];
ax.RTickLabel={'','15','30','45','60','75',''};
ax.RDir='reverse';
ax.ThetaTickLabel={'North','30^{o}','60^{o}','East','120^{o}','150^{o}','South','210^{o}','240^{o}','West','300^{o}','330^{o}'};
% legend(leg);
set(gca,'FontName','Times New Roman','ThetaDir','clockwise','GridLineStyle','--','Fontsize',11);
2. 绘图结果
参考链接