0001 function xsum = csum(x,n)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 if isstruct(x) && isfield(x,'real')
0017 if nargin==1
0018 xsum.real = sum(x.real);
0019 xsum.imag = sum(x.imag);
0020 elseif nargin==2
0021 xsum.real = sum(x.real,n);
0022 xsum.imag = sum(x.imag,n);
0023 end
0024
0025 elseif isnumeric(x)
0026 if nargin==1
0027 xsum = sum(x);
0028 elseif nargin==2
0029 xsum = sum(x,n);
0030 end
0031 else
0032 ME = MException('csum:inputError', ...
0033 'Input does not have the expected format.');
0034 throw(ME);
0035 end
0036
0037 end