📄 err_chk.m
字号:
fprintf(' %d latitude variable(s) out of %d\n',length(I_lat),...
size(estruct.variable(i).var,1));
fprintf(' were found to be out of bounds in input %s to function %s.\n', ...
estruct.variable(i).name, upper(estruct.func_name));
fprintf(' Valid values are between -pi/2 and pi/2.\n');
fprintf(' Type "help %s" for correct units and details.\n', ...
lower(estruct.func_name));
fprintf(' Resulting use of these variables may cause subsequent ');
fprintf('functions to fail.\n\n');
dbstack
fprintf('\n');
end % if DEBUG_MODE == 0
end % if ~isempty(I_lat)
% Find out of bounds longitude values
I_long = find(estruct.variable(i).var(:,2) < lla_rad_min(2) | ...
estruct.variable(i).var(:,2) > lla_rad_max(2));
if ~isempty(I_long)
if DEBUG_MODE == 0
fprintf('Warning from Constellation Toolbox Error Checking.\n');
fprintf(' %d longitude variable(s) out of %d\n',length(I_long),...
size(estruct.variable(i).var,1));
fprintf(' were found to be out of bounds in input %s to function %s.\n', ...
estruct.variable(i).name, upper(estruct.func_name));
fprintf(' Valid values are between -pi and 2*pi.\n');
fprintf(' Type "help %s" for correct units and details.\n', ...
lower(estruct.func_name));
fprintf('functions to fail.\n\n');
dbstack
fprintf('\n');
end % if DEBUG_MODE == 0
end % if ~isempty(I_lat)
elseif strcmp(estruct.variable(i).type,'GPS_TIME')
% Check that the inputs are within the error bounds
gps_time_min = [0 0]; % min GPS week and seconds
gps_time_max = [3640 604800]; % max GPS week and seconds
% Find out of bounds latitude values
I_week = find(estruct.variable(i).var(:,1) < gps_time_min(1) | ...
estruct.variable(i).var(:,1) > gps_time_max(1));
if ~isempty(I_week)
if DEBUG_MODE == 0
fprintf('Error from Constellation Toolbox Error Checking.\n');
fprintf(' %d GPS week variable(s) out of %d\n',length(I_week),...
size(estruct.variable(i).var,1));
fprintf(' were found to be out of bounds in input %s to function %s.\n', ...
estruct.variable(i).name, upper(estruct.func_name));
fprintf(' Valid values are between 0 and 3640.\n');
fprintf(' Type "help %s" for correct units and details.\n', ...
lower(estruct.func_name));
fprintf(' Resulting use of these variables may cause subsequent ');
fprintf('functions to fail.\n\n');
dbstack
fprintf('\n');
% Invalid GPS times set the stop flag when in DEBUG_MODE == 0
stop_flag = 1;
end % if DEBUG_MODE == 0
end % if ~isempty(I_week)
% Find out of bounds longitude values
I_sec = find(estruct.variable(i).var(:,2) < gps_time_min(2) | ...
estruct.variable(i).var(:,2) > gps_time_max(2));
if ~isempty(I_sec)
if DEBUG_MODE == 0
fprintf('Error from Constellation Toolbox Error Checking.\n');
fprintf(' %d GPS seconds variable(s) out of %d\n',length(I_sec),...
size(estruct.variable(i).var,1));
fprintf(' were found to be out of bounds in input %s to function %s.\n', ...
estruct.variable(i).name, upper(estruct.func_name));
fprintf(' Valid values are between 0 and 604800.\n');
fprintf(' Type "help %s" for correct units and details.\n', ...
lower(estruct.func_name));
fprintf(' Resulting use of these variables may cause subsequent ');
fprintf('functions to fail.\n\n');
dbstack
fprintf('\n');
% Invalid GPS times set the stop flag when in DEBUG_MODE == 0
stop_flag = 1;
end % if DEBUG_MODE == 0
end % if ~isempty(I_lat)
elseif strcmp(estruct.variable(i).type,'ANGLE_RAD')
% Check that the inputs are within the error bounds
ang_rad_min = -2*pi; % min mod 2*pi angle
ang_rad_max = 2*pi; % max mod 2*pi angle
% Find out of bounds latitude values
I_ang = find(estruct.variable(i).var < ang_rad_min(1) | ...
estruct.variable(i).var > ang_rad_max(1));
if ~isempty(I_ang)
if DEBUG_MODE == 0
fprintf('Warning from Constellation Toolbox Error Checking.\n');
fprintf(' %d angular variable(s) out of %d\n',length(I_ang),...
size(estruct.variable(i).var,1));
fprintf(' were found to be out of bounds in input %s to function %s.\n', ...
estruct.variable(i).name, upper(estruct.func_name));
fprintf(' Valid values are between -2*pi and 2*pi.\n');
fprintf(' Type "help %s" for correct units and details.\n', ...
lower(estruct.func_name));
fprintf(' Resulting use of these variables may cause subsequent ');
fprintf('functions to fail.\n\n');
dbstack
fprintf('\n');
end % if DEBUG_MODE == 0
end % if ~isempty(I_lat)
elseif strcmp(estruct.variable(i).type,'ELEVATION_RAD')
% Check that the inputs are within the error bounds
ang_rad_min = -pi/2; % min mod -pi/2 angle
ang_rad_max = pi/2; % max mod pi/2 angle
% Find out of bounds latitude values
I_ang = find(estruct.variable(i).var < ang_rad_min(1) | ...
estruct.variable(i).var > ang_rad_max(1));
if ~isempty(I_ang)
if DEBUG_MODE == 0
fprintf('Warning from Constellation Toolbox Error Checking.\n');
fprintf(' %d elevation variable(s) out of %d\n',length(I_ang),...
size(estruct.variable(i).var,1));
fprintf(' were found to be out of bounds in input %s to function %s.\n', ...
estruct.variable(i).name, upper(estruct.func_name));
fprintf(' Valid values are between -pi/2 and pi/2.\n');
fprintf(' Type "help %s" for correct units and details.\n', ...
lower(estruct.func_name));
fprintf(' Resulting use of these variables may cause subsequent ');
fprintf('functions to fail.\n\n');
dbstack
fprintf('\n');
end % if DEBUG_MODE == 0
end % if ~isempty(I_lat)
elseif strcmp(estruct.variable(i).type,'ELEVATION_RAD_0')
% Check that the inputs are within the error bounds
ang_rad_min = 0; % min 0 angle
ang_rad_max = pi/2; % max mod pi/2 angle
% Find out of bounds latitude values
I_ang = find(estruct.variable(i).var < ang_rad_min(1) | ...
estruct.variable(i).var > ang_rad_max(1));
if ~isempty(I_ang)
if DEBUG_MODE == 0
fprintf('Warning from Constellation Toolbox Error Checking.\n');
fprintf(' %d elevation variable(s) out of %d\n',length(I_ang),...
size(estruct.variable(i).var,1));
fprintf(' were found to be out of bounds in input %s to function %s.\n', ...
estruct.variable(i).name, upper(estruct.func_name));
fprintf(' Valid values are between 0 and pi/2.\n');
fprintf(' Type "help %s" for correct units and details.\n', ...
lower(estruct.func_name));
fprintf(' Resulting use of these variables may cause subsequent ');
fprintf('functions to fail.\n\n');
dbstack
fprintf('\n');
end % if DEBUG_MODE == 0
end % if ~isempty(I_lat)
elseif strcmp(estruct.variable(i).type,'KEPLER_ORBIT')
% Check that the inputs are within the error bounds
earth_radius = 6378137.0; % WGS-84 Earth radius meters
% Compute apogee radius
% a
ra = estruct.variable(i).var(:,1) .* (1 + estruct.variable(i).var(:,2));
rp = estruct.variable(i).var(:,1) .* (1 - estruct.variable(i).var(:,2));
% Find out of bounds latitude values
I_apsis = find(ra < earth_radius & rp < earth_radius);
if ~isempty(I_apsis)
if DEBUG_MODE == 0
fprintf('Warning from Constellation Toolbox Error Checking.\n');
fprintf(' %d Keplerian orbits orbit(s) out of %d\n',length(I_apsis),...
size(estruct.variable(i).var,1));
fprintf(' were found to be out of bounds in input %s to function %s.\n', ...
estruct.variable(i).name, upper(estruct.func_name));
fprintf(' Valid orbits have an apogee or perigee greater than\n');
fprintf(' the radius of the Earth (6378137 m). Check inputs for\n');
fprintf(' correct units on semi-major axis (a).\n');
fprintf(' Type "help %s" for correct units and details.\n', ...
lower(estruct.func_name));
fprintf(' Resulting use of these variables may cause subsequent ');
fprintf('functions to fail.\n\n');
dbstack
fprintf('\n');
end % if DEBUG_MODE == 0
end % if ~isempty(I_apsis)
elseif strcmp(estruct.variable(i).type,'STRING')
if ~isstr(estruct.variable(i).var)
if DEBUG_MODE == 0
fprintf('Error from Constellation Toolbox Error Checking.\n');
fprintf(' Input %s to function %s must be a string.\n', ...
estruct.variable(i).name, upper(estruct.func_name));
fprintf(' Type "help %s" for correct units and details.\n', ...
lower(estruct.func_name));
fprintf(' Resulting use of these variables may cause subsequent ');
fprintf('functions to fail.\n\n');
dbstack
fprintf('\n');
% Invalid GPS times set the stop flag when in DEBUG_MODE == 0
stop_flag = 1;
end % if DEBUG_MODE == 0
end % if ~isempty(I_week)
elseif ~isempty(estruct.variable(i).type)
fprintf('Unknowm variable type %s for input variable %s from function %s.\n',...
estruct.variable(i).type, estruct.variable(i).name, ...
upper(estruct.func_name));
fprintf('Check the error checking inputs for this function.\n\n');
dbstack
fprintf('\n');
end % if strcmp(estruct.variable(i).type,'LLA_RAD')
% If the variable type was declared, check for NaN, inf, and real
% Check for NaN
I_nan = find(isnan(estruct.variable(i).var) == 1);
% Check for Nan, if there are any, issues a warning
if ~isempty(I_nan)
if DEBUG_MODE == 0 | DEBUG_MODE == 1
fprintf('Warning from Constellation Toolbox Error Checking.\n');
fprintf(' %d NaN variables found in input %s to function %s.\n', ...
length(I_nan),estruct.variable(i).name, upper(estruct.func_name));
fprintf('Resulting use of these variables may cause subsequent ');
fprintf('functions to fail.\n\n');
dbstack
fprintf('\n');
end % if DEBUG_MODE == 0 | DEBUG_MODE == 1
end % if ~isempty(I_nan)
% Check for inf
I_inf = find(isinf(estruct.variable(i).var) == 1);
% Check for inf, if there are any, issues a warning
if ~isempty(I_inf)
if DEBUG_MODE == 0 | DEBUG_MODE == 1
fprintf('Warning from Constellation Toolbox Error Checking.\n');
fprintf(' %d inf variables found in input %s to function %s.\n', ...
length(I_inf),estruct.variable(i).name, upper(estruct.func_name));
fprintf('Resulting use of these variables may cause subsequent ');
fprintf('functions to fail.\n\n');
dbstack
fprintf('\n');
end % if DEBUG_MODE == 0 | DEBUG_MODE == 1
end % if ~isempty(I_nan)
% Check for real, if there are any, issues a warning
if ~isreal(estruct.variable(i).var)
if DEBUG_MODE == 0 | DEBUG_MODE == 1
fprintf('Warning from Constellation Toolbox Error Checking.\n');
fprintf(' %s variable in input to function %s is not real.\n', ...
estruct.variable(i).name, upper(estruct.func_name));
fprintf('Resulting use of these variables may cause subsequent ');
fprintf('functions to fail.\n\n');
dbstack
fprintf('\n');
end % if DEBUG_MODE == 0 | DEBUG_MODE == 1
end % if ~isempty(I_nan)
end % if ~isempty(estruct.variable(i).type)
end % for i = 1:num_to_check
% end of ERR_CHK
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -