-
Notifications
You must be signed in to change notification settings - Fork 7
/
explcore.m
69 lines (54 loc) · 1.48 KB
/
explcore.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function [Comb,ExplVariat]=explcore(G,n);
%EXPLCORE For interpretation of cores and arrays
%
%
% function [Comb,ExplVariat]=explcore(G,Fac,n);
% 'explcore.m'
%
% This algorithm requires access to:
% 'two2n.m'
%
% [Comb,ExplVariat,ExplVarian]=explcore(G,n);
%
% G : Core array from Tucker3 model
% n : Show only the 'n' largest factor combinations.
%
% Copyright (C) 1995-2006 Rasmus Bro & Claus Andersson
% Copenhagen University, DK-1958 Frederiksberg, Denmark, rb@life.ku.dk
%
% $ Version 2.00 $ May 2001 $ Changed to array notation $ RB $ Not compiled $
% $ Version 1.03 $ Date 28. Oct 1999 $ Not compiled $ 'improved help'
% $ Version 1.02 $ Date 17. Sep 1998 $ Not compiled $
DimG = size(G);
G = reshape(G,DimG(1),prod(DimG(2:end)));
Fac = DimG;
if ~exist('n'),
n=10;
end;
if n>length(G(:));
n=length(G(:));
end;
C=length(Fac(1,:));
Par=zeros(1,C);
ssgunc=sum(G(:).^2);
fprintf('Col1: Number in list\n');
fprintf('Col2: Index to elements\n');
fprintf('Col3: Explained variation (sum of squares) of the core.\n');
fprintf('Col4: Core entry.\n');
fprintf('Col5: Sq. core entry.\n');
for l=1:n,
[i j]=max(G(:).^2);
[a b]=find(G==G(j));
a=a(1);
b=b(1);
Par=two2n(Fac,[a b]);
fprintf('%2i ',l);
fprintf('(');
for c=1:C-1,
fprintf('%2i,',Par(c));
end;
Comb(l,:)=Par;
ExplVariat(l)=100*G(a,b).^2/ssgunc;
fprintf('%2i) %15.5f%% %15.5f %15.5f\n',Par(C),ExplVariat(l),G(a,b),G(a,b).^2);
G(a,b)=0;
end;