Mercurial > hg > ltpda
comparison m-toolbox/m/gui/ltpdv/callbacks/ltpdv_save_objects.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 function ltpdv_save_objects(varargin) | |
2 | |
3 % Handles | |
4 myh = varargin{1}; | |
5 mainfig = varargin{end}; | |
6 | |
7 % Get selected objects | |
8 objs = ltpdv_get_selected_objs(mainfig); | |
9 | |
10 % Get filename from user | |
11 [filename, pathname] = uiputfile( ... | |
12 {'*.mat','MAT-files (*.mat)'; ... | |
13 '*.xml','LTPDA-XML-files (*.xml)'}, ... | |
14 'Save as') | |
15 | |
16 | |
17 if isequal(filename,0) || isequal(pathname,0) | |
18 disp('Cancelled.') | |
19 else | |
20 fname = fullfile(pathname, filename); | |
21 % split filename up | |
22 [pathstr, name, ext] = fileparts(fname); | |
23 | |
24 switch ext | |
25 case '.mat' | |
26 | |
27 save(objs, fname); | |
28 | |
29 case '.xml' | |
30 | |
31 | |
32 % Save each object | |
33 for j=1:numel(objs) | |
34 | |
35 obj = objs{j}; | |
36 | |
37 % filename | |
38 fname = fullfile(pathstr, sprintf('%s_%03d%s', name, j, ext)); | |
39 | |
40 % save object | |
41 save(obj, fname) | |
42 | |
43 end | |
44 | |
45 otherwise | |
46 error('### Unsupported file format.'); | |
47 end | |
48 | |
49 | |
50 | |
51 end | |
52 | |
53 | |
54 | |
55 | |
56 | |
57 % END |