0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 function buildObj(varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 mainfig = varargin{end};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % get object name
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 varh = findobj(mainfig.handle, 'Tag', 'VariableTxt');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 varname = get(varh, 'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 % get base workspace variables
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 ws_vars = evalin('base','who');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % check if this one is there or not
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 if ismember(varname, ws_vars)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 j = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 vname = varname;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 while ismember(vname, ws_vars)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 vname = sprintf('%s_%03d', varname, j);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 j = j + 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 vname = varname;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 disp(sprintf('** exporting to %s', vname));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 % get constructor string
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 h = findobj(mainfig.handle, 'Tag', 'ConstructorDisplay');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 cstr = get(h, 'String');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 cmd = sprintf('%s = %s;', vname, cstr);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 evalin('base', cmd);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 end
|