📄 fttuckp1.m
字号:
function [Ypred,R]=fttuckp1(Xcal,r1,r2,r3,W1,W2,W3,Xpred,Ycal,CenMode);
%function [Ypred,R]=fttuckp1(Xcal,r1,r2,r3,W1,W2,W3,Xpred,Ycal,CenMode);
%
%This particular procedure (fttuckp1) calculates the regression
%coefficients of the modelling of Y from A*R=Y. A is calculated
%from the solution to the TUCKER3 model.
%NOTE:This predictor is build to, and should ONLY be used with,
%solutions from FTTUCK01.M (same scheme for updating A)
%
% Xcal : Supermatrix (r1 x r2穜3) from cube (r1 x r2 x r3).
% This supermatrix contains the EEM's for which the
% concentration will be determined.
% r1,r2,r3 : Number of observations along each way.
% W1,W2,W3 : Number of factors along each way.
% Xpred : Supermatrix (rp x r2穜3) with objects whose
% Y-values must be estimated.
% Ycal : Y values to use for calibration, must have same
% number of rows as Xcal. Ycal (r1 x ry)
% CenMode : If CenMode=0 no centering else centering.
% Ypred : Ypred (rp x ry) Predicted values for the objects
% contained in Xpred.
% R : Regression coefficients. R (W1 x ry)
% Author : Claus A. Andersson, May 1995
% Copyright: Food Technology,
% Royal Veterinary & Agricultural University
% Copenhagen, Denmark
% E-mail : claus.andersson@pop.foodsci.kvl.dk
%Centers X
if CenMode==1,
st=ones(size(Xcal,1),1);
Xcen=mean(Xcal);
Xcal=Xcal-st*Xcen;
end;
%Calculates the scores of the calibration matrix
[Acal Bcal Ccal Gcal]=fttuck01(Xcal,r1,r2,r3,W1,W2,W3,1,0);
%Centers Y
if CenMode==1,
st=ones(size(Ycal,1),1);
Ycen=mean(Ycal);
Ycal=Ycal-st*Ycen;
end;
%Calculates the regression coefficients in R
R=(Acal'*Acal)\Acal'*Ycal;
%Centers Xpred
if CenMode==1,
st=ones(size(Xpred,1),1);
Xpred=Xpred-st*Xcen;
end;
%Determines scores of the new material in Xnew
rpred1=size(Xpred,1);
tmp2=zeros(W1,r3*r2);
for k=1:r3,
tmp1=Ccal(k,1)*Gcal(:,1:W2)*Bcal';
for l=2:W3,
tmp1=tmp1+Ccal(k,l)*Gcal(:,(l-1)*W2+1:l*W2)*Bcal';
end;
tmp2(1:W1,(k-1)*r2+1:k*r2)=tmp1;
end;
Apred=Xpred*tmp2'/(tmp2*tmp2');
%Predicts Y from new score
Ypred=Apred*R;
%Adds from centering
if CenMode==1,
st=ones(size(Ypred,1),1);
Ypred=Ypred+st*Ycen;
end;
disp('FTTUCKP1: Execution ended.')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -