📄 fttuck04.m
字号:
function [A,B,C,G]=fttuck04(X,r1,r2,r3,W1,W2,W3);
%function [A B C G]=fttuck04(X,r1,r2,r3,W1,W2,W3);
%
%This TUCKER3 program calculates the W principal components in
%the problem Z = A(w1)*G(w1,w2,w3)*(B(w2)kronC(w3)) for wi=1,2,...,W(i);
%
%This particular procedure (fttuck04) is not iterative and simply
%calculates a core from the factors found by TUCKER1/UPCA
%
% 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.
% A,B,C : The found factors in columns.
% The dimensions will be A(r1 x W1) B(r2 x W2) C(r3 x W3).
% G : Cube of interactions, the CORE
% Author : Claus A. Andersson, May 1995
% Copyright: Food Technology,
% Royal Veterinary & Agricultural University
% Copenhagen, Denmark
% E-mail : claus.andersson@pop.foodsci.kvl.dk
disp('Calling FTUPCA01.M')
[A B C]=ftupca01(X,r1,r2,r3,W1,W2,W3);
%Updating G - the core
tmp1=zeros(W1*W2,r3);
for t=1:r3,
tmp=(A'*X(1:r1,(t-1)*r2+1:t*r2)*B)';
tmp1(:,t)=tmp(:);
end;
tmp2=kron(A'*A,B'*B)\tmp1*C/(C'*C);
G=zeros(W1,W2*W3);
for t=1:W3,
G(1:W1,(t-1)*W2+1:t*W2)=reshape(tmp2(:,t)',W2,W1)';
end;
clear tmp tmp1 tmp2 t
%Calculates the misfit of factors and core
diff=0;
for k=1:r3
tmp1=G(:,1:W2)*C(k,1);
for l=2:W3
tmp1=tmp1+G(:,(l-1)*W2+1:l*W2)*C(k,l);
end;
diff=diff+sum(sum((X(:,(k-1)*r2+1:k*r2)-A*tmp1*B').^2));
end;
fprintf('The sq. sum of misfit is %12.8f with the found factors. \n',diff);
disp('FTTUCK04: Execution ended.')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -