-
Notifications
You must be signed in to change notification settings - Fork 8
/
LoadWorkSpace.m
executable file
·112 lines (97 loc) · 3.1 KB
/
LoadWorkSpace.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
function LoadWorkSpace
global TDALABHOME Y tdalabStatus;
% if isemtpy(Y)
% errordlg('Did not load any data yet.');
% end
global NumOfComp NumOfMode;
global algNames algParas Ynoise noiseSNR;
global MCTimes MCelapsedTime MCSIRs MCfit;
global elapsedTime SIRs fit Ycap;
global loadedVars loadedFileName;
global algs algOptions;
[WSFileName WSFilePath]=uigetfile('*.mat','Load a workspace ...',horzcat(TDALABHOME,filesep,'userdata'));
if isequal(WSFileName,0)
return;
end
MCFileName=horzcat(WSFilePath,WSFileName);
ws=load(MCFileName);
loadedFileName=ws.Exp.dataFile;
fvars=whos('-file',loadedFileName);
loadedVars={fvars(:).name};
FileName=regexp(ws.Exp.dataFile,filesep,'split');
FileName=FileName{end};
h=allchild(0);
oo = findall(h, 'Tag', 'TDALAB' );
set(oo,'name',[FileName,' :: ',defstr('TDALAB')]);
TDALABinitialization;
tdalabStatus=struct();
algParas=struct();
fs=fieldnames(ws.Exp);
for idx=1:numel(fs)
eval([fs{idx} '=ws.Exp.(fs{idx});']);
end
%% load source tensor data
data=load(ws.Exp.dataFile);
if isempty(data)
errstr=horzcat('The file ',ws.Exp.dataFile,' does not exist.');
errordlg(errstr,'Open error');
return;
end
varnames=fieldnames(data);
idx=find(strcmpi(varnames,ws.Exp.Y));
h=findobj('tag','ppSelVar');
set(h,'string',varnames,'enable','on','value',idx);
Y=data.(varnames{idx});
NumOfMode=numel(size(Y));
if ~isempty(Ycap)
switch lower(tdalabStatus.model)
case {'cp','tucker'}
NumOfComp=reshape(cellfun(@(x) size(x,2),Ycap.U(:)),1,[]);
case {'bcd'}
end
else
if find(strcmpi({'ttensor','ktensor'},class(Y)))
NumOfComp=reshape(cellfun(@(x) size(x,2),Y.U(:)),1,[]);
else
NumOfComp=[];
end
end
updateUI;
%% update algs information
if ~tdalabStatus.advEvaluation
h=findobj('tag','pmAlgList');
idx=find(strcmpi({algs(tdalabStatus.validAlgs).name},ws.Exp.algNames));
if idx>0
set(h,'value',idx);
idx= strcmpi({algs(:).name},ws.Exp.algNames);
algOptions{idx==1}=ws.Exp.algParas;
tdalabStatus.algIndex=find(idx==1);
else
errordlg(horzcat('The algorithm [', ws.Exp.algNames, '] has been removed.'));
end
else % MC RUN
%% update tdalabStatus.algIndex
pos=1;
for idx=1:numel(ws.Exp.algNames)
cidx=find(strcmpi({algs(:).name},ws.Exp.algNames{idx}));
if cidx>0
tdalabStatus.algIndex(pos)=cidx;
algOptions{cidx}=ws.Exp.algParas.(ws.Exp.algNames{idx});
pos=pos+1;
end
end
end %% update algs
%%command visualization
commandwindow;
tdalab('hide');
fprintf('Algorithm: %s [%s].\n',algs(tdalabStatus.algIndex).details,algs(tdalabStatus.algIndex).name);
fprintf('Elapsed time of this run: %f sec. Fit=%3.2f%%.\n\n',elapsedTime,fit*100);
if ~all(isnan(SIRs))
SIRs=real(SIRs);
CPdispSIRs(SIRs);
end
fprintf('========================== Load complete ==========================\n\n');
fprintf('\n[TDALAB] Type or click <a href="matlab: tdalab">tdalab</a> to return.\n\n');
pause(1);
tdalab('show');
end