我在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
答案 0 :(得分:2)
如果S_4值随时间变化,颜色编码是否会在单行内发生变化?
它可能不是最有效的方式,但你可以为每一条轨道绘制线条。喜欢
s4code = [1 0 0; 0 0 1]; % blue & red
for i = time_vector
if s4(i) > something
s = 2
else
s = 1
end
line(x(i:(i+1)), y(i:(i+1)), 'color', s4code(s, :))
end
关于轨道数据和s4数据不具有相同的大小...使它们具有相同的大小...例如interp1 ;-)
答案 1 :(得分:2)
如果您使用极坐标绘图,请尝试3D Polar Plot(Ken Garrard的FEX代码)
如果您使用plot
,请尝试Colored line or scatter plot或cline.m(再次使用FEX文件)
最后一个情节是通过以下方式完成的:
x = 1:300
color_line(x,sin(x/20),sin(x/20))