📄 plotsky.m
字号:
function p_handle = plotsky(az,el,prn_pass,plot_title,spoke_label)
% p_handle = plotsky(az,el,prn,plot_title,spoke_label);
%
% Function to plot the trajectories on a polar sky (azimuth/elevation) plot
% for a single observer. Each arc generated by a satellite is colored and
% labeled with the prn number. This function will use the current figure
% if one is available. Otherwise, a figure will be created. Zoom
% capability is added to the figure. See help on ZOOM for more information.
% Starting points are not labeled and end points are labeled
% with 'x'.
%
% Input:
% az - azimuth (-pi to 2*pi rad) (nx1)
% el - elevation (-pi/2 to pi/2 rad) (nx1)
% prn_pass - [satellite number, pass number], nx1 or nx2 (optional),
% pass numbers are computed by PASSDATA.
% if not provided, a single line is drawn
% plot_title - title of plot (1xm string) (optional) default = 'Sky Plot'
% spoke_label - labels for the North, East, South,and West spokes of the
% plot. (4xn string) (optional).
% default = str2mat('N','E','S','W')
% Output:
% p_handle - graphics handle to the figure
%
% See also PLOTPASS
% Written by: Jimmy LaMance 11/7/96
% Modified by: Maria Evans 5/5/98
% Copyright (c) 1998 by Constell, Inc.
% functions called: ERR_CHK, PLOTPOLR
%%%%% BEGIN VARIABLE CHECKING CODE %%%%%
% declare the global debug variable
global DEBUG_MODE
% Initialize the output variables
p_handle=[];
% Check the number of input arguments and issues a message if invalid
msg = nargchk(2,5,nargin);
if ~isempty(msg)
fprintf('%s See help on PLOTSKY for details.\n',msg);
fprintf('Returning with empty outputs.\n\n');
return
end
% check that the size of the prn_pass input is valid, if provided
if nargin < 3,
prn_pass = zeros(size(plot_data,1),2);
end % if nargin < 3
% Check to make sure the title string is a valid size
if nargin < 4,
plot_title = ['Sky Plot'];
end % if nargin == 4
if nargin < 5
spoke_label = str2mat('N','E','S','W');
end % if nargin >= 5
% Get the current Matlab version
matlab_version = version;
matlab_version = str2num(matlab_version(1));
% If the Matlab version is 5.x and the DEBUG_MODE flag is not set
% then set up the error checking structure and call the error routine.
if matlab_version >= 5.0
estruct.func_name = 'PLOTSKY';
% Develop the error checking structure with required dimension, matching
% dimension flags, and input dimensions.
estruct.variable(1).name = 'az';
estruct.variable(1).req_dim = [901 1];
estruct.variable(1).var = az;
estruct.variable(1).type = 'ANGLE_RAD';
estruct.variable(2).name = 'el';
estruct.variable(2).req_dim = [901 1];
estruct.variable(2).var = el;
estruct.variable(2).type = 'ELEVATION_RAD';
estruct.variable(3).name = 'prn_pass';
estruct.variable(3).req_dim = [901 1; 901 2;];
estruct.variable(3).var = prn_pass;
% Call the error checking function
stop_flag = err_chk(estruct);
if stop_flag == 1
fprintf('Invalid inputs to %s. Returning with empty outputs.\n\n', ...
estruct.func_name);
return
end % if stop_flag == 1
end % if matlab_version >= 5.0 & isempty(DEBUG_MODE)
%%%%% END VARIABLE CHECKING CODE %%%%%
%%%%% BEGIN ALGORITHM CODE %%%%%
% Determine how many satellites are involved and plot them 1 at a time
active_sats = []; % starting value for the active satellites matrix
prn = prn_pass(:,1);
if size(prn_pass,2)==2,,
pass = prn_pass(:,2);
else,
pass = ones(size(prn));
end;
prn_nums = unique(prn);
num_prns = length(prn_nums);
for i = 1:num_prns % loop over possible prn numnbers
I = find(prn == prn_nums(i)); % find the matches
if ~isempty(I) % if there is a match,
active_sats = [active_sats prn(I(1))]; % add that prn to the active list
end % if any(I)
end % for
avail_colors = ['gmycrb'];
num_colors = length(avail_colors);
for i = 1:size(active_sats,2) % loop over the active satellites
J = find(prn == active_sats(i)); % all satellites with the same prn number
% Determine how many passes for this PRN
pass_sort = sort(pass(J));
pass_change = find(diff(pass_sort) ~= 0);
% create a matrix that has sorted and reduced pass numbers [1 2 4 5 6 8 ... 28]
pass_nums = [pass_sort(pass_change); pass_sort(length(pass_sort))];
num_passes = length(pass_nums);
% verify that some satellites were found
if any(J)
label_color = avail_colors(rem(i,num_colors) + 1); % cycle through colors
for k = 1:num_passes,
I = find(prn == active_sats(i) & pass == pass_nums(k));
% plot the az/el pairs for this satellite
p_handle = ...
plotpolr(az(I),el(I),'-',num2str(active_sats(i)),label_color,spoke_label);
% clear out the I variable
clear I
% make sure that the hold state is on
if ishold == 0
hold on
end % if ishold == 0
end;
end % if any(I)
end % for
title(plot_title);
zoom on
% set the plot label to be Satellite Sky Plot if it is not already named
if isempty(get(gcf,'Name'))==1,
set(gcf,'Name','Satellite Sky Plot')
end;
hold off
%%%%% END ALGORITHM CODE %%%%%
% end PLOTSKY
function hpol = plotpolr(az,el,line_style,prn_label,label_color,spoke_label)
% hpol = plotpolr(az,el,line_style,prn_label,label_color,spoke_label);
%
% Azimuth-Elevation polar coordinate plot. Plots a line based on azimuth and
% elevation data with optional inputs for labeling and coloring of the line.
%
% Inputs:
% az - azimuth vector (rad) (nx1)
% valid values are -2*pi -> 2*pi
% el - elevation vector (rad) (nx1)
% valid values are -pi/2 -> pi/2
% line_style - line style to use for this line (string) (optional).
% These are the Matlab character designations for line styles
% [. o x + - * : -. --], default is the Matlab 'auto'
% prn_label - label to identify the az/el line (string) (optional)
% default is no label
% label_color - color for the line and label (string) (optional).
% These are the Matlab letter designations for colors
% [y m c r g b w k], default is the Matlab 'auto'
% spoke_label - labels for the North, East, South,and West spokes of the
% plot. (4xn string) (optional).
% default = str2mat('N','E','S','W')
%
% Outputs:
% hpol - handle to the plot created
%
% See also PLOTSKY, NED2AZEL, ECEF2NED
% Written by: Jimmy LaMance 11/7/96
% Copyright (c) 1998 by Constell, Inc.
% functions called: none
%%%%% BEGIN VARIABLE CHECKING CODE %%%%%
% declare the global debug variable
global DEBUG_MODE
% Initialize the output variables
p_handle=[];
% Check the number of input arguments and issues a message if invalid
msg = nargchk(2,6,nargin);
if ~isempty(msg)
fprintf('%s See help on PLOTPOLR for details.\n',msg);
fprintf('Returning with empty outputs.\n\n');
return
end
% check if the line style is provided, if not use the default of auto
if nargin < 3 % no line style variable is provided
line_style = 'auto'; % set to auto mode (default)
end % if nargin < 3
% check if the prn label is provided, if not use the default of '' (no label)
if nargin < 4 % no prn label variable is provided
prn_label = ''; % set to '' (default)
end % if nargin < 4
% check if the label color is provided, if not use the default of auto
if nargin < 5 % no line style variable is provided
label_color = ''; % set to auto mode (default)
end % if nargin < 5
% check that the input spoke labels are correct dimension or set to the
% default values
if nargin < 6
spoke_label = str2mat('N','E','S','W');
end % if nargin >= 6
% Get the current Matlab version
matlab_version = version;
matlab_version = str2num(matlab_version(1));
% If the Matlab version is 5.x and the DEBUG_MODE flag is not set
% then set up the error checking structure and call the error routine.
if matlab_version >= 5.0
estruct.func_name = 'PLOTPOLR';
% Develop the error checking structure with required dimension, matching
% dimension flags, and input dimensions.
estruct.variable(1).name = 'az';
estruct.variable(1).req_dim = [901 1];
estruct.variable(1).var = az;
estruct.variable(1).type = 'ANGLE_RAD';
estruct.variable(2).name = 'el';
estruct.variable(2).req_dim = [901 1];
estruct.variable(2).var = el;
estruct.variable(2).type = 'ELEVATION_RAD';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -