tsqmtx.m

来自「PLS_Toolbox是用于故障检测与诊断方面的matlab工具箱」· M 代码 · 共 33 行

M
33
字号
function [tsqmat,tsqs] = tsqmtx(x,p,ssq);
%TSQMTX calculates matrix for T^2 contributions for PCA
%  Given a data matrix (x), loadings (p), and variance
%  table (ssq). TSQMTX calculates the matrix for indivual
%  variable contributions to Hotelling's T^2 (tsqmat) and
%  Hotelling's T^2 (tsqs). If s is the covariance matrix
%  then tsqmat = x*p*sqrt(inv(s))*p';
% 
%I/O: [tsqmat,tsqs] = tsqmtx(x,p,ssq);
%  
%  Note: The data matrix (x) must be scaled in a similar
%  manner to the data used to determine the loadings (p).
%
%See also: PCA, PCAPRO, RESMTX

%Copyright Eigenvector Research, Inc. 1996-98
%Modified: NBG 10/96,7/97

[mx,nx] = size(x);
[mp,np] = size(p);
if mp~=nx
  error('Size of x and p not compatible')
end
tsqmat  = x*p;
mp      = 1./sqrt(ssq(1:np,2));
tsqmat  = tsqmat*diag(mp);
if np>1
  tsqs  = sum((tsqmat.^2)')';
else
  tsqs  = tsqmat.^2;
end
tsqmat  = tsqmat*p';

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?