home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 5
/
ctrom5b.zip
/
ctrom5b
/
WINDOWS
/
DIVERSEN
/
MATHS171
/
TRACE.M
< prev
next >
Wrap
Text File
|
1993-03-23
|
348b
|
20 lines
function y = trace(X)
%y=trace(X)
%trace Compute the trace of matrix X
% S.Halevy 7/31/92
% Copyright (c) 1992 by the MathWizards
if nargin < 1
error('not enough arguments')
end
if nargin > 1
error('too many arguments')
end
if isvector(X)
error('trace - argument must be a matrix')
end
y = sum(diag(X));