matlab - 我想使用 Matlab 对卫星轨迹图进行颜色编码

标签 matlab colors plot gradient

我正在 Matlab 中创建一个绘图,用于绘制多个 GPS 卫星随时间变化的方位角和仰角。下面是绘制的 GPS 卫星轨迹的图像示例。

satellite trajectory plot

不过,我还想在同一张图上绘制 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

最佳答案

如果 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 ;-)

关于matlab - 我想使用 Matlab 对卫星轨迹图进行颜色编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13677648/

相关文章:

algorithm - 使用 MATLAB 查找点中的所有多边形

android - 如何更改 AlertDialog.Builder AppCompat 中项目的颜色?

r - 在 r、ggplot2、lattice 或latticeExtra 中创建更连续的调色板

plot - 如何在 Gadfly 图中设置图形大小或绘图大小(使用 Julia)?

plot - 如何使用非数字 X 轴绘制数据?

database - 将 Matlab float 组插入 postgresql float[] 列

linux - 适用于 LINUX 的 MATLAB 编译器

css - 获取 RGBA over RGB 的输出颜色

matlab - 如何使用 subplot 绘制导入的 .fig 文件中的所有内容(同时保留图例+轴+标签)?

matlab - 加载mat文件并直接分配给matlab中的变量