📄 ftopti01.m
字号:
function [A,B,C,G]=ftopti01(X,r1,r2,r3,W1,W2,W3,startmode,convlim,Ai,Bi,Ci...
,model,frA,frB,frC);
%function [A,B,C,G]=ftopti01(X,r1,r2,r3,W1,W2,W3,startmode,convlim,Ai,Bi,Ci...
% ,model,frA,frB,frC);
%
%This program (ftopti01) make it possible to gain huge speed
%advantages by reducing the data material significantly.
%
%The use of this optimizer can only be recommended if the data is
%highly continuous, eg. absorbance spectre or fluoroscence spectre.
%
%If You do not use the option of giving initial guesses, You can
%enter zeros instead of Ai, Bi and Ci, eg. ..,0,0,0,..
%
% X : Supermatrix (r1 x r2穜3) from cube (r1 x r2 x r3).
% Corresponds to mode 1 in the 'ftfixfom.m'
% r1,r2,r3 : Number of observations along each way.
% W1,W2,W3 : Number of factors,
% You must give equal W1, W2 and W3 if PARAFAC is used.
% startmode: Use 'help ..' on the program You wish to use.
% convlim : Max. difference between two successive sq. sums of misfits.
% Ai,Bi,Ci : Initial guesses on A, B and C from the user.
%
% model : String variable, containing the name of the program
% to solve by, e.g. 'ftpara02'. Use lower-case letters.
% Use 'help ..' on the program you wish to use.
% Programs currently for use with this optimizer are:
% 'ftpara01'
% 'ftpara02'
% 'ftpara03'
% 'fttuck01'
% 'fttuck02'
% 'fttuck03'
%
% frA : Use each frA'th point along the first way, (often=1)
% Beware that it is in general NOT a good idea to interpolate
% between object scores, since these often are discontinuous.
% Therefore you should allways use 1 along the object axis,
% provided that such an axis exists.
% frB : Use each frB'th point along the second way,
% frC : Use each frC'th point along the third way,
%
% A,B,C : The found factors in columns.
% G : Cube of interactions, the socalled CORE,
% contains data if TUCKER is used, else empty.
% Author : Claus A. Andersson, May 1995
% Copyright: Food Technology,
% Royal Veterinary & Agricultural University
% Copenhagen, Denmark
% E-mail : claus.andersson@pop.foodsci.kvl.dk
%
if length(Ai)<r1, Ai=randn(r1,W1)+1; end;
if length(Bi)<r2, Bi=randn(r2,W2)+1; end;
if length(Ci)<r3, Ci=randn(r3,W3)+1; end;
%Reducing X to Xm
LA=1:frA:r1;
if LA(length(LA))<r1,
LA=[LA r1];
end;
r1m=length(LA);
LB=1:frB:r2;
if LB(length(LB))<r2,
LB=[LB r2];
end;
r2m=length(LB);
LC=1:frC:r3;
if LC(length(LC))<r3,
LC=[LC r3];
end;
r3m=length(LC);
%Extracts the LA-points
Xm=X(LA,:);
Aim=Ai(LA,:);
%Extracts the LB-points
tmp=ftfixfom(Xm,1,2,r1m,r2,r3);
tmp=tmp(LB,:);
Bim=Bi(LB,:);
Xm=ftfixfom(tmp,2,1,r1m,r2m,r3);
%Extracts the LC-points
tmp=ftfixfom(Xm,1,3,r1m,r2m,r3);
tmp=tmp(LC,:);
Xm=ftfixfom(tmp,3,1,r1m,r2m,r3m);
Cim=Ci(LC,:);
disp('OPTI: Data reduced. Now calling the program specified.')
%Calling the right routines
if model=='ftpara01',
disp('OPTI: Using ftpara01')
[Am Bm Cm]=ftpara01(Xm,r1m,r2m,r3m,W1,startmode,convlim,Aim,Bim,Cim);
end;
if model=='ftpara02',
disp('OPTI: Using ftpara02')
[Am Bm Cm]=ftpara02(Xm,r1m,r2m,r3m,W1,startmode,convlim,Aim,Bim,Cim);
end;
if model=='ftpara03',
disp('OPTI: Using ftpara03')
[Am Bm Cm]=ftpara03(Xm,r1m,r2m,r3m,W1,startmode,convlim,Aim,Bim,Cim);
end;
if model=='fttuck01',
disp('OPTI: Using fttuck01')
[Am Bm Cm Gm]=fttuck01(Xm,r1m,r2m,r3m,W1,W2,W3,startmode,convlim,Aim,Bim,Cim);
end;
if model=='fttuck02',
disp('OPTI: Using fttuck02')
[Am Bm Cm Gm]=fttuck02(Xm,r1m,r2m,r3m,W1,W2,W3,startmode,convlim,Aim,Bim,Cim);
end;
if model=='fttuck03',
disp('OPTI: Using fttuck03')
[Am Bm Cm Gm]=fttuck03(Xm,r1m,r2m,r3m,W1,W2,W3,startmode,convlim,Aim,Bim,Cim);
end;
%Interpolate the factors
A=zeros(r1,W1);
for w=1:W1,
for t=1:r1m-1,
for u=LA(t):LA(t+1),
A(u,w)=(Am(t+1,w)-Am(t,w))/(LA(t+1)-LA(t))*(u-LA(t)) + Am(t,w);
end;
end;
end;
B=zeros(r2,W2);
for w=1:W2,
for t=1:r2m-1,
for u=LB(t):LB(t+1),
B(u,w)=(Bm(t+1,w)-Bm(t,w))/(LB(t+1)-LB(t))*(u-LB(t)) + Bm(t,w);
end;
end;
end;
C=zeros(r3,W3);
for w=1:W3,
for t=1:r3m-1,
for u=LC(t):LC(t+1),
C(u,w)=(Cm(t+1,w)-Cm(t,w))/(LC(t+1)-LC(t))*(u-LC(t)) + Cm(t,w);
end;
end;
end;
disp('OPTI: Factors interpolated.')
disp('OPTI: Calling the program again with full factors.')
%Calling the right routines
if model=='ftpara01',
[A B C]=ftpara01(X,r1,r2,r3,W1,2,convlim,A,B,C);
end;
if model=='ftpara02',
[A B C]=ftpara02(X,r1,r2,r3,W1,2,convlim,A,B,C);
end;
if model=='ftpara03',
[A B C]=ftpara03(X,r1,r2,r3,W1,2,convlim,A,B,C);
end;
if model=='fttuck01',
[A B C G]=fttuck01(X,r1,r2,r3,W1,W2,W3,2,convlim,A,B,C);
end;
if model=='fttuck02',
[A B C G]=fttuck02(X,r1,r2,r3,W1,W2,W3,2,convlim,A,B,C);
end;
if model=='fttuck03',
[A B C G]=fttuck03(X,r1,r2,r3,W1,W2,W3,2,convlim,A,B,C);
end;
disp('FTOPTI01: Factors adjusted - solutions found.')
disp('FTOPTI01: Execution ended.')
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -