-
Notifications
You must be signed in to change notification settings - Fork 8
/
selectVars.m
executable file
·58 lines (56 loc) · 1.83 KB
/
selectVars.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
function selectVars
global Y NumOfMode NumOfComp loadedVars tdalabStatus loadedFileName;
TDModelstr=defstr('tdmodel');
h=findobj('tag','ppSelVar');
index=get(h,'value');
names=loadedVars;
selvar=load(loadedFileName,names{index});
if isempty(selvar)
error('[TDALAB] The source file has been modified. Please reload it.');
end
selvar=selvar.(names{index});
clsvar=class(selvar);
hmodel=findobj('tag','pmTDModel');
inputFormatstr=defstr('input');
if ~any(strcmpi(inputFormatstr,clsvar))&&~any(strcmpi({'double','tensor'},clsvar))
h=findobj('tag','txtNoTensorInfor');
set(h,'visible','on');
set(h,'string',{selvar});
elseif strcmp(clsvar,'double')||strcmp(clsvar,'tensor')
Y=selvar;Y=tensor(Y);
cleartemp;
tdalabStatus.inputType='tensor';
tdalabStatus.model='CP';
tdalabStatus.fullTensor=true;
sz=size(Y);NumOfMode=length(sz);
NumOfComp=0;
NumOfComp=NumOfComp(ones(1,NumOfMode));
set(hmodel,'value',find(strcmpi(TDModelstr,tdalabStatus.model),1));
updateUI;
elseif strcmp(clsvar,'ktensor')
Y=selvar;
cleartemp;
tdalabStatus.inputType='ktensor';
tdalabStatus.model='CP';
tdalabStatus.fullTensor=false;
NumOfMode=length(size(Y));
NumOfComp=length(Y.lambda);
NumOfComp=NumOfComp(ones(1,NumOfMode));
set(hmodel,'value',find(strcmpi(TDModelstr,tdalabStatus.model),1));
updateUI;
elseif strcmp(clsvar,'ttensor')
Y=selvar;
Y=ttensor(tensor(Y.core),Y.U);
cleartemp;
tdalabStatus.inputType='ttensor';
tdalabStatus.model='Tucker';
tdalabStatus.fullTensor=false;
NumOfComp=size(Y.core);
NumOfMode=length(size(Y));
set(hmodel,'value',find(strcmpi(TDModelstr,tdalabStatus.model),1));
updateUI;
else
errordlg(['Unsuported data type: [',class(Y),'].'],'Type error','modal');
return;
end
end