Excisit.m
Revision as of 14:55, 5 August 2010 by 128.111.101.185 (talk) (Created page with '<pre> % EXCISEIT.M % Combines excise and exciseCol % Mfile to excise any row containing data less than -1000 from entire % matrix based on trapflags in col. % Modified to include…')
% EXCISEIT.M
% Combines excise and exciseCol
% Mfile to excise any row containing data less than -1000 from entire
% matrix based on trapflags in col.
% Modified to include low and high thresholds as with excise.m
% SRW 1998
% Created: JCS - someTime 1992 (:
% useage: exciseit(file,<col>,<LOWER_THRESHOLD>,<UPPER_THRESHOLD>)
% If col is <=0, or not specified then operates as excise.
% If col is >0, then operates as exciseCol with the addition of
% LOWER_THRESHOLD, UPPER_THRESHOLD.
function [x,yrow,nrow]=exciseit(x,col,LOWER_THRESHOLD, UPPER_THRESHOLD)
if exist('UPPER_THRESHOLD') ~= 1,
UPPER_THRESHOLD = 1e34;
end
if exist('LOWER_THRESHOLD') ~= 1,
LOWER_THRESHOLD = -1000;
end
% $$$ if exist('col') ==1,
% $$$ if col<=0,
% $$$ col=[];
% $$$ end
% $$$ else
% $$$ col=[];
% $$$ end
%col set for all columns
if ~exist('col') | col==0,
col=[];
%col set for all columns but those in original col
elseif col<0,
col=-col;
xcol=[1:size(x,2)];
xcol(col)=[];
col=xcol;
end
%look for error flags in any column
[m,n]=size(x);
if isempty(col),
trap= (x < LOWER_THRESHOLD | x > UPPER_THRESHOLD | ...
isnan(x) == 1 | isinf(x) == 1);
if n > 1,
trap=any(trap')';
end
nrow=find(trap);
else
%look for error flags in columns=[col]
trap=zeros(m,n);
trap(:,col) = (x(:,col) < LOWER_THRESHOLD | x(:,col)> UPPER_THRESHOLD | ...
isnan(x(:,col)) == 1 | isinf(x(:,col)) == 1);
nrow=find(any(trap'));
end
x(nrow,:)=[];
yrow=ones(m,1);
yrow(nrow)=0;
yrow=find(yrow);