0001 function outdata = zeromean(indata, start, stop)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 if (nargin < 1) | (size(indata,1)==0) | (size(indata,1)==0)
0016 error('Function requires at least one argument, a rectangular matrix.');
0017 end;
0018
0019 if nargin == 1
0020 start = 1;
0021 stop = size(indata,1);
0022 end;
0023 if nargin == 2
0024 if start >= size(indata,1)
0025 error('Start argument must be less than # of data matrix rows.');
0026 end;
0027 stop = size(indata,1);
0028 end;
0029 if nargin >= 3
0030 if start >= size(indata,1)
0031 error('Start argument must be less than # of data matrix rows.');
0032 end;
0033 if stop > size(indata,1)
0034 error('Stop argument must be less than # of data matrix rows.');
0035 end;
0036 if stop <= start
0037 error('Stop argument must be greater than start argument.');
0038 end;
0039 if nargin > 3
0040 disp('Ignoring arguments beyond the third.');
0041 end;
0042 end;
0043
0044 outdata = zeros(size(indata));
0045
0046 datamean = mean(indata(start:stop,:));
0047 datamean = ones(size(indata,1),1) * datamean;
0048
0049 outdata = indata - datamean;
0050 return