-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnipals.m
executable file
·90 lines (71 loc) · 2.17 KB
/
nipals.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
function RESULTS = nipals(X, prepro, a, it, tol)
%%
% This function requires the function scaledata.m available at:
% http://www.mathworks.com/matlabcentral/fileexchange/15561-data-scaling
%
% This function requires the function convert2table.m available at:
% http://www.mathworks.com/matlabcentral/fileexchange/52170-convert2table
%
% Written by: Filippo Amato July 2015
%
% RESULTS = nipals(X, prepro, a, it, tol)
%
% X = data matrix (if it is not a TABLE it will be converted)
% prepro = type of matrix preprocessing (see below)
% a = number of components
% it = maximum number of iterations for one component
% tol = tolerance. default = 20000
%
% Submit data matrix in the form of a TABLE. This form is
% prefearable.
% Objects on the ROWS and variables on the COLUMNS.
% Select the proper preprocessing method:
%
% 0 = raw matrix
% 1 = matrix column-centered
% 2 = autoscaled matrix
%
%
% HIGHLY IMPORTANT
%
% If the labels for the objects are in the first column of the table
% and they were not given as TABLE.Properties.RowNames, then launch
% the function with the command:
%
% nipals(X(:,2:end), .....)
% In general submit only the numerical part of X.
%
% to automatically generate rownames import the data from xlsx
% (object names in the first column) file with
% the command:
%
% X = readtable('file.xlsx', 'ReadRowNames', true)
%=========================================================================
set(0,'DefaultFigureWindowStyle','docked');
ExistTable = istable(X);
if ExistTable==1
TABLE = X;
OriginalData = X;
X = table2array(X);
[a,LargeX] = max(std(X));
elseif ExistTable ==0
X = convert2table(X);
OriginalData = X;
TABLE = X;
X = table2array(X);
[a,LargeX] = max(std(X));
end
[rows, cols] = size(X);
Z = X;
run('nipals_conditions.m')
run('nipals_prepro.m')
RESULTS = nipals_decomp(Z,rows, cols, a, it, tol, LargeX);
RESULTS.OriginalData = OriginalData;
if prepro==0
RESULTS.X_Raw = Z;
elseif prepro==1
RESULTS.X_Centered = Z;
elseif prepro==2
RESULTS.X_Autoscaled = Z;
end
run('nipals_figures.m')