?? iscor.m
字號:
function t = iscor(R)
%ISCOV Is a matrix a correlation matrix?
% T = ISCOV(R) returns a logical value indicating whether or not the
% matrix R is a valid correlation matrix, i.e., whether it is symmetric,
% positive semidefinite, with ones on the diagonal.
% Written by Peter Perkins, The MathWorks, Inc.
% Revision: 1.0 Date: 2003/09/05
% This function is not supported by The MathWorks, Inc.
%
% Requires MATLAB R13.
[n,m] = size(R);
% test square, unit diagonal, symmetric
if (n == m) && all(diag(R) == 1) && all(all(abs(R - R') < 10*eps))
e = eig(.5*(R + R'));
% test positive semidefinite
if all(e > -abs(max(e))*n*eps)
t = true;
else
t = false;
end
else
t = false;
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -