Mercurial > hg > ltpda
comparison m-toolbox/classes/+utils/@xml/attachVectorToDom.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 | |
2 function attachVectorToDom(numbers, dom, parent) | |
3 | |
4 shape = sprintf('%dx%d', size(numbers)); | |
5 | |
6 %%%%% Real data %%%%% | |
7 realNode = dom.createElement('realData'); | |
8 realNode.setAttribute('type', 'doubleVector'); | |
9 realNode.setAttribute('shape', shape); | |
10 | |
11 %%% Set the parent attribute 'type' to vector | |
12 parent.setAttribute('type', 'doubleVector'); | |
13 parent.appendChild(realNode); | |
14 | |
15 idx = 1; | |
16 Ndata = numel(numbers); | |
17 n = min(utils.xml.MAX_DOUBLE_IN_ROW, Ndata); | |
18 while idx-1 <= Ndata | |
19 | |
20 numberStr = strtrim(utils.helper.num2str(real(numbers(idx:min(Ndata,idx+n-1))))); | |
21 if ~isempty(numberStr) | |
22 %%% Create new vector node | |
23 content = dom.createTextNode(numberStr); | |
24 vectorNode = dom.createElement('doubleVector'); | |
25 vectorNode.setAttribute('type', class(numbers)); | |
26 vectorNode.appendChild(content); | |
27 realNode.appendChild(vectorNode); | |
28 end | |
29 idx = idx + n; | |
30 end | |
31 | |
32 %%%%% Imaginary data %%%%% | |
33 if ~isreal(numbers) | |
34 imagNode = dom.createElement('imagData'); | |
35 imagNode.setAttribute('type', 'doubleVector') | |
36 parent.appendChild(imagNode); | |
37 | |
38 idx = 1; | |
39 while idx-1 <= Ndata | |
40 numberStr = strtrim(utils.helper.num2str(imag(numbers(idx:min(Ndata,idx+n-1))))); | |
41 if ~isempty(numberStr) | |
42 content = dom.createTextNode(numberStr); | |
43 vectorNode = dom.createElement('doubleVector'); | |
44 vectorNode.setAttribute('type', class(numbers)); | |
45 vectorNode.appendChild(content); | |
46 imagNode.appendChild(vectorNode); | |
47 end | |
48 idx = idx + n; | |
49 end | |
50 end | |
51 | |
52 end |