ftupca01.m

来自「Tucker, PARAFAC, GRAM, RAFA and misc. 2n」· M 代码 · 共 44 行

M
44
字号
function [A,B,C]=ftupca01(X,r1,r2,r3,W1,W2,W3);
%function [A,B,C]=ftupca01(X,r1,r2,r3,W1,W2,W3);
%
%This UNFOLD-PCA or TUCKER1 program calculates the Wi factors in
%the problem X approx. = sum (A(w1)*B(w2)*C(w3)) for wi=1,2,...,Wi;
%
%This particular procedure (ftupca01) pertains no constraints at all
%and has been constructed so that the required memory will be minimal.
%
% X        : Supermatrix (r1 x r2穜3) from cube (r1 x r2 x r3).
% r1,r2,r3 : Number of observations along each way.
% W1,W2,W3 : Number of factors along each way.
% A,B,C	   : The found factors in columns. 
%            The dimensions will be A(r1 x W1) B(r2 x W1) C(r3 x W1).
% Author   : Claus A. Andersson, May 1995 
% Copyright: Food Technology,
%            Royal Veterinary & Agricultural University
%            Copenhagen, Denmark
% E-mail   : claus.andersson@pop.foodsci.kvl.dk

%Find orthogonal A's and B's
tmp1=X(1:r1,1:r2) * X(1:r1,1:r2)';
tmp2=X(1:r1,1:r2)'* X(1:r1,1:r2);
for t=2:r3,
 tmp1=tmp1+X(1:r1,(t-1)*r2+1:t*r2) * X(1:r1,(t-1)*r2+1:t*r2)';
 tmp2=tmp2+X(1:r1,(t-1)*r2+1:t*r2)'* X(1:r1,(t-1)*r2+1:t*r2);
end;
tmp=tmp/r3;
[A tmp]=fnipals1(tmp1,W1);
[B tmp]=fnipals1(tmp2,W2);

%Find orthogonal C's
tmp2=zeros(r3,r3);
for t=1:r2;
  tmp1=zeros(r1,r3);
  for u=1:r3,
    tmp1(1:r1,u)=X(1:r1,(u-1)*r2+t);
  end;
  tmp2=tmp2+tmp1'*tmp1;
end;
tmp=tmp/r2;
[C tmp]=fnipals1(tmp2,W3);

disp('FTUPCA01: Execution ended.')

⌨️ 快捷键说明

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