Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@helper/saveobj.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 varargout = saveobj(a, pl) | |
2 % SAVEOBJ saves an object to a file. | |
3 % | |
4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
5 % | |
6 % DESCRIPTION: SAVEOBJ saves an object to a file. | |
7 % | |
8 % CALL: saveobj(obj, pl) | |
9 % | |
10 % INPUTS: obj - an object (for example, an AO) | |
11 % pl - parameter list with a 'filename' parameter | |
12 % | |
13 % Supported file types are '.mat' and '.xml'. | |
14 % | |
15 % OUTPUTS: | |
16 % | |
17 % VERSION: $Id: saveobj.m,v 1.3 2010/09/17 14:12:31 ingo Exp $ | |
18 % | |
19 % HISTORY: 28-08-2007 M Hewitson | |
20 % Creation | |
21 % | |
22 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
23 | |
24 % get filename | |
25 filename = find(pl, 'filename'); | |
26 | |
27 % Inspect filename | |
28 [path,name,ext] = fileparts(filename); | |
29 | |
30 switch ext | |
31 case '.mat' | |
32 | |
33 save(filename, 'a'); | |
34 | |
35 case '.xml' | |
36 | |
37 % convert object to xml | |
38 xml = com.mathworks.xml.XMLUtils.createDocument('ltpda_object'); | |
39 parent = xml.getDocumentElement; | |
40 | |
41 utils.xml.xmlwrite(a, xml, parent, ''); % Save the XML document. | |
42 xmlwrite(filename, xml); | |
43 | |
44 otherwise | |
45 error('### unknown file extension.'); | |
46 end | |
47 |