⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ncosine.m

📁 多维数据处理:MATLAB源程序用于处理多维数据
💻 M
字号:
function [MultPhi,Phis] = ncosine(factor1,factor2,DimX,Fac);

% $ Version 1.02 $ Date 28. July 1998 $ Not compiled $
%
% Copyright, 1998 - 
% This M-file and the code in it belongs to the holder of the
% copyrights and is made public under the following constraints:
% It must not be changed or modified and code cannot be added.
% The file must be regarded as read-only. Furthermore, the
% code can not be made part of anything but the 'N-way Toolbox'.
% In case of doubt, contact the holder of the copyrights.
%
% Rasmus Bro
% Chemometrics Group, Food Technology
% Department of Food and Dairy Science
% Royal Veterinary and Agricultutal University
% Rolighedsvej 30, DK-1958 Frederiksberg, Denmark
% Phone  +45 35283296
% Fax    +45 35283245
% E-mail rb@kvl.dk
%
%
% MULTIPLE COSINE/TUCKERS CONGRUENCE COEFFICIENT
%
% [MultPhi,Phis] = ncosine(factor1,factor2,DimX,Fac);
%
% ----------------------INPUT---------------------
%
% factor1 	=[A(:);B(:);C(:)] for a three-way array
% factor2 	=[A(:);B(:);C(:)] for a three-way array
% 		If factor1 and factor2 are identical then
%       	the multiple cosine of a given solution is
% 	        estimated; otherwise the similarity of the
% 	        two different solutions is given
% DimX		Dimension of array
%
% ----------------------OUTPUT---------------------
%
% MultPhi	Is the multiple cosine of the model
% Phis		Is the cosine between components in
%	        individual component matrices arranged
%	        as [PhiA;PhiB ...]
%
%
%	Copyright
%	Rasmus Bro 1995/1997
%	Royal Veterinary & Agricultural University
%	Denmark
%	E-mail rb@kvl.dk

if length(factor1)~=length(factor2)
  error(' factor1 and factor2 must be vectors of same length in NCOSINE.M')
end
ord=length(DimX);
l_idx=0;
Fac=length(factor1)/sum(DimX);
for o=1:ord
  l_idx=[l_idx sum(DimX(1:o))*Fac];
end
L1=reshape(factor1(1:DimX(1)*Fac),DimX(1),Fac);
L2=reshape(factor2(1:DimX(1)*Fac),DimX(1),Fac);
for f=1:Fac
  L1(:,f)=L1(:,f)/norm(L1(:,f));
  L2(:,f)=L2(:,f)/norm(L2(:,f));
end
Phis=L2'*L2;
MultPhi=Phis;

for i=2:ord
  L1=reshape(factor1(l_idx(i)+1:l_idx(i+1)),DimX(i),Fac);
  L2=reshape(factor2(l_idx(i)+1:l_idx(i+1)),DimX(i),Fac);
  for f=1:Fac
    L1(:,f)=L1(:,f)/norm(L1(:,f));
    L2(:,f)=L2(:,f)/norm(L2(:,f));
  end
  phi=(L1'*L2);
  MultPhi=MultPhi.*phi;
  Phis=[Phis;phi];
end

⌨️ 快捷键说明

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