我在 Matlab 中创建了一个绘图,它随着时间的推移绘制几个 GPS 卫星的方位角和仰角。下面是绘制的 GPS 卫星轨迹的图像示例。
但是,我还想S_4
在同一个图上绘制指数(电离层引起的闪烁效应)。我想对每个 GPS 卫星路径进行颜色编码,以将高S_4
索引显示为红色,将低S_4
索引显示为蓝色。我有所有这些的数据,但我无法找到对每条 GPS 路径进行颜色编码的方法。
目前我知道每颗卫星在一天中的每一秒的位置(这就是我绘制轨迹的方式)。我也有S_4
不同时间和不同卫星的索引值(S_4
索引矩阵与卫星位置矩阵的大小不同)。
有任何想法吗?
这是我使用的功能。它使用一个矩阵作为输入plotMat
:
plotMat=[svID(satellite id number), gpsSec, elevation(radians), azimuth(radians)]
我的功能:
% find out from 'plotMat' if plotting satellite locations or trajectories in
% addition determine how many satellites are being tracked and how many
% samples for each satellite (# samples / satellite must always be equal)
gpsTime = plotMat(1,2);
i = 1;
t = gpsTime;
while ((i ~= size(plotMat,1)) & (t == gpsTime))
i = i + 1;
t = plotMat(i,2);
end
if (t == gpsTime)
sats = i;
else
sats = i - 1;
end;
samples = size(plotMat,1) / sats;
SVs = plotMat(1:sats,1);
elevation = plotMat(:,3);
azimuth = plotMat(:,4);
% initialize polar - plotting area
figure(10);clf;
axis([-1.4 1.4 -1.1 1.1]);
axis('off');
axis(axis);
hold on;
% plot circular axis and labels
th = 0:pi/50:2*pi;
x = [ cos(th) .67.*cos(th) .33.*cos(th) ];
y = [ sin(th) .67.*sin(th) .33.*sin(th) ];
plot(x,y,'color','w');
text(1.1,0,'90','horizontalalignment','center');
text(0,1.1,'0','horizontalalignment','center');
text(-1.1,0,'270','horizontalalignment','center');
text(0,-1.1,'180','horizontalalignment','center');
% plot spoke axis and labels
th = (1:6)*2*pi/12;
x = [ -cos(th); cos(th) ];
y = [ -sin(th); sin(th) ];
plot(x,y,'color','w');
text(-.46,.93,'0','horizontalalignment','center');
text(-.30,.66,'30','horizontalalignment','center');
text(-.13,.36,'60','horizontalalignment','center');
text(.04,.07,'90','horizontalalignment','center');
% plot titles
if (samples == 1)
title('Satellite Position Plot');
subtitle = sprintf('GPS time : %.2f sec',plotMat(1,2));
else
title('Satellite Trajectory Plot');
subtitle = sprintf('GPS time range : %.2f sec to %.2f sec', ...
plotMat(1,2),plotMat(size(plotMat,1),2));
text(-1.6,1,'SVID/Last Position','color','r');
text(-1.6,.9,'Positive Elevation','color','y');
text(-1.6,.8,'Negative Elevation','color','b');
end
text(0,-1.3,subtitle,'horizontalalignment','center');
% plot trajectories (or positions) and label the last postion with the
% satellite SV id; in addition, last postions are in red, otherwise position
% elevations are yellow and negative elavations are blue
%
% loop through samples
for s = 1:samples
% plot each satellite location for that sample
for sv = 1:sats
% check if positive or negative elevation
if (elevation((s - 1) * sats + sv) < 0)
elNeg = 1;
else
elNeg = 0;
end
% convert to plottable cartesian coordinates
el = elevation((s - 1) * sats + sv);
az = azimuth((s - 1) * sats + sv);
x = (pi/2-abs(el))/(pi/2).*cos(az-pi/2);
y = -1*(pi/2-abs(el))/(pi/2).*sin(az-pi/2);
% check for final sample
if (s == samples)
plot(x,y,'r*');
text(x,y+.07,int2str(SVs(sv)), ...
'horizontalalignment', ...
'center','color','r');
else
% check for +/- elevation
if (elNeg == 0)
plot(x,y,'y.');
else
plot(x,y,'b.');
end
end
end
end
axis equal;
在前面的代码中,我没有添加S_4
索引。以下代码将闪烁 ( S_4
) 数据上的 GPS 秒数与具有卫星位置数据的 GPS 秒数进行比较。矩阵scint.mat
指闪烁数据,而txinfo.mat
指卫星位置数据。此代码创建一个与 GPS 秒数和卫星识别号一致的组合代码。
load('scint_324_first')
scint = scint';
load('txinfo_324_first_wrw')
txinfo = txinfo';
k = 0;
for i = 1:length(scint)
disp(num2str(i))
for j = 1:length(txinfo)
if scint(i,2) == txinfo(j,2) && scint(i,15) == txinfo(j,8)
k = k+1;
combo(k,:) = [scint(i,:) txinfo(j,:)];
end
end
end