0001 function xml = xml_add_data(xml, d)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 el = xml.docNode.createElement('Data');
0013
0014
0015
0016
0017 if isa(d, 'tsdata')
0018
0019
0020 elc = xml.docNode.createElement('Type');
0021 elc.appendChild(xml.docNode.createTextNode('tsdata'));
0022 el.appendChild(elc);
0023
0024
0025 elc = xml.docNode.createElement('Name');
0026 elc.appendChild(xml.docNode.createTextNode(d.name));
0027 el.appendChild(elc);
0028
0029
0030 elc = xml.docNode.createElement('Fs');
0031 elc.appendChild(xml.docNode.createTextNode(num2str(d.fs)));
0032 el.appendChild(elc);
0033
0034
0035 elc = xml.docNode.createElement('Xunits');
0036 elc.appendChild(xml.docNode.createTextNode(d.xunits));
0037 el.appendChild(elc);
0038
0039
0040 elc = xml.docNode.createElement('Yunits');
0041 elc.appendChild(xml.docNode.createTextNode(d.yunits));
0042 el.appendChild(elc);
0043
0044
0045 elc = xml.docNode.createElement('Version');
0046 elc.appendChild(xml.docNode.createTextNode(d.version));
0047 el.appendChild(elc);
0048
0049
0050 elc = xml.docNode.createElement('Created');
0051 elc.appendChild(xml.docNode.createTextNode(d.created));
0052 el.appendChild(elc);
0053
0054 if isreal(d.x)
0055
0056
0057 elc = xml.docNode.createElement('dType');
0058 elc.appendChild(xml.docNode.createTextNode('real'));
0059 el.appendChild(elc);
0060
0061
0062 elc = xml.docNode.createElement('Data');
0063 x = d.x;
0064 nmin = getappdata(0, 'xmlsetsize');
0065 while ~isempty(x)
0066 elcc = xml.docNode.createElement('YSet');
0067 n = min(length(x), nmin);
0068 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', x(1:n))));
0069 x = x(n+1:end);
0070 elc.appendChild(elcc);
0071 end
0072 el.appendChild(elc);
0073 else
0074
0075 elc = xml.docNode.createElement('dType');
0076 elc.appendChild(xml.docNode.createTextNode('complex'));
0077 el.appendChild(elc);
0078
0079
0080 elc = xml.docNode.createElement('Data');
0081 x = d.x;
0082 nmin = getappdata(0, 'xmlsetsize');
0083 while ~isempty(x)
0084 n = min(length(x), nmin);
0085 elcc = xml.docNode.createElement('rYSet');
0086 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', real(x(1:n)))));
0087 elc.appendChild(elcc);
0088 elcc = xml.docNode.createElement('iYSet');
0089 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', imag(x(1:n)))));
0090 elc.appendChild(elcc);
0091 x = x(n+1:end);
0092 end
0093 el.appendChild(elc);
0094 end
0095
0096
0097
0098 elseif isa(d, 'xydata')
0099
0100
0101
0102 elc = xml.docNode.createElement('Type');
0103 elc.appendChild(xml.docNode.createTextNode('xydata'));
0104 el.appendChild(elc);
0105
0106
0107 elc = xml.docNode.createElement('Name');
0108 elc.appendChild(xml.docNode.createTextNode(d.name));
0109 el.appendChild(elc);
0110
0111
0112 elc = xml.docNode.createElement('Xunits');
0113 elc.appendChild(xml.docNode.createTextNode(d.xunits));
0114 el.appendChild(elc);
0115
0116
0117 elc = xml.docNode.createElement('Yunits');
0118 elc.appendChild(xml.docNode.createTextNode(d.yunits));
0119 el.appendChild(elc);
0120
0121
0122 elc = xml.docNode.createElement('Version');
0123 elc.appendChild(xml.docNode.createTextNode(d.version));
0124 el.appendChild(elc);
0125
0126
0127 elc = xml.docNode.createElement('Created');
0128 elc.appendChild(xml.docNode.createTextNode(d.created));
0129 el.appendChild(elc);
0130
0131 if isreal(d.y)
0132
0133 elc = xml.docNode.createElement('dType');
0134 elc.appendChild(xml.docNode.createTextNode('real'));
0135 el.appendChild(elc);
0136
0137
0138 elc = xml.docNode.createElement('Data');
0139 x = d.x;
0140 nmin = getappdata(0, 'xmlsetsize');
0141 while ~isempty(x)
0142 elcc = xml.docNode.createElement('XSet');
0143 n = min(length(x), nmin);
0144 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', x(1:n))));
0145 x = x(n+1:end);
0146 elc.appendChild(elcc);
0147 end
0148
0149 y = d.y;
0150 nmin = getappdata(0, 'xmlsetsize');
0151 while ~isempty(y)
0152 elcc = xml.docNode.createElement('YSet');
0153 n = min(length(y), nmin);
0154 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', y(1:n))));
0155 y = y(n+1:end);
0156 elc.appendChild(elcc);
0157 end
0158 el.appendChild(elc);
0159 else
0160
0161 elc = xml.docNode.createElement('dType');
0162 elc.appendChild(xml.docNode.createTextNode('complex'));
0163 el.appendChild(elc);
0164
0165
0166 elc = xml.docNode.createElement('Data');
0167 y = d.y;
0168 nmin = getappdata(0, 'xmlsetsize');
0169 while ~isempty(y)
0170 n = min(length(y), nmin);
0171 elcc = xml.docNode.createElement('rYSet');
0172 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', real(y(1:n)))));
0173 elc.appendChild(elcc);
0174 elcc = xml.docNode.createElement('iYSet');
0175 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', imag(y(1:n)))));
0176 elc.appendChild(elcc);
0177 y = y(n+1:end);
0178 end
0179
0180 x = d.x;
0181 nmin = getappdata(0, 'xmlsetsize');
0182 while ~isempty(x)
0183 elcc = xml.docNode.createElement('XSet');
0184 n = min(length(x), nmin);
0185 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', x(1:n))));
0186 x = x(n+1:end);
0187 elc.appendChild(elcc);
0188 end
0189 el.appendChild(elc);
0190 end
0191
0192
0193
0194 elseif isa(d, 'cdata')
0195
0196 elc = xml.docNode.createElement('Type');
0197 elc.appendChild(xml.docNode.createTextNode('cdata'));
0198 el.appendChild(elc);
0199
0200
0201 elc = xml.docNode.createElement('Name');
0202 elc.appendChild(xml.docNode.createTextNode(d.name));
0203 el.appendChild(elc);
0204
0205
0206 elc = xml.docNode.createElement('Xunits');
0207 elc.appendChild(xml.docNode.createTextNode(d.xunits));
0208 el.appendChild(elc);
0209
0210
0211 elc = xml.docNode.createElement('Yunits');
0212 elc.appendChild(xml.docNode.createTextNode(d.yunits));
0213 el.appendChild(elc);
0214
0215
0216 elc = xml.docNode.createElement('Version');
0217 elc.appendChild(xml.docNode.createTextNode(d.version));
0218 el.appendChild(elc);
0219
0220
0221 elc = xml.docNode.createElement('Created');
0222 elc.appendChild(xml.docNode.createTextNode(d.created));
0223 el.appendChild(elc);
0224
0225
0226 elc = xml.docNode.createElement('Shape');
0227 elc.appendChild(xml.docNode.createTextNode(num2str(size(d.vals))));
0228 el.appendChild(elc);
0229
0230 if isreal(d.vals)
0231
0232 elc = xml.docNode.createElement('dType');
0233 elc.appendChild(xml.docNode.createTextNode('real'));
0234 el.appendChild(elc);
0235
0236
0237 elc = xml.docNode.createElement('Data');
0238 x = d.vals;
0239 nmin = getappdata(0, 'xmlsetsize');
0240 while ~isempty(x)
0241 elcc = xml.docNode.createElement('YSet');
0242 n = min(length(x), nmin);
0243 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', x(1:n))));
0244 x = x(n+1:end);
0245 elc.appendChild(elcc);
0246 end
0247 el.appendChild(elc);
0248 else
0249
0250 elc = xml.docNode.createElement('dType');
0251 elc.appendChild(xml.docNode.createTextNode('complex'));
0252 el.appendChild(elc);
0253
0254
0255 elc = xml.docNode.createElement('Data');
0256 x = d.vals;
0257 nmin = getappdata(0, 'xmlsetsize');
0258 while ~isempty(x)
0259 n = min(length(x), nmin);
0260 elcc = xml.docNode.createElement('rYSet');
0261 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', real(x(1:n)))));
0262 elc.appendChild(elcc);
0263 elcc = xml.docNode.createElement('iYSet');
0264 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', imag(x(1:n)))));
0265 elc.appendChild(elcc);
0266 x = x(n+1:end);
0267 end
0268 el.appendChild(elc);
0269 end
0270
0271
0272
0273 elseif isa(d, 'fsdata')
0274
0275
0276 elc = xml.docNode.createElement('Type');
0277 elc.appendChild(xml.docNode.createTextNode('fsdata'));
0278 el.appendChild(elc);
0279
0280
0281 elc = xml.docNode.createElement('Name');
0282 elc.appendChild(xml.docNode.createTextNode(d.name));
0283 el.appendChild(elc);
0284
0285
0286 elc = xml.docNode.createElement('Fs');
0287 elc.appendChild(xml.docNode.createTextNode(num2str(d.fs)));
0288 el.appendChild(elc);
0289
0290
0291 elc = xml.docNode.createElement('ENBW');
0292 elc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', d.enbw)));
0293 el.appendChild(elc);
0294
0295
0296 elc = xml.docNode.createElement('Navs');
0297 elc.appendChild(xml.docNode.createTextNode(num2str(d.navs)));
0298 el.appendChild(elc);
0299
0300
0301 elc = xml.docNode.createElement('Xunits');
0302 elc.appendChild(xml.docNode.createTextNode(d.xunits));
0303 el.appendChild(elc);
0304
0305
0306 elc = xml.docNode.createElement('Yunits');
0307 elc.appendChild(xml.docNode.createTextNode(d.yunits));
0308 el.appendChild(elc);
0309
0310
0311 elc = xml.docNode.createElement('Version');
0312 elc.appendChild(xml.docNode.createTextNode(d.version));
0313 el.appendChild(elc);
0314
0315
0316 elc = xml.docNode.createElement('Created');
0317 elc.appendChild(xml.docNode.createTextNode(d.created));
0318 el.appendChild(elc);
0319
0320 if isreal(d.xx)
0321
0322 elc = xml.docNode.createElement('dType');
0323 elc.appendChild(xml.docNode.createTextNode('real'));
0324 el.appendChild(elc);
0325
0326
0327 elc = xml.docNode.createElement('Data');
0328 x = d.xx;
0329 nmin = getappdata(0, 'xmlsetsize');
0330 while ~isempty(x)
0331 elcc = xml.docNode.createElement('YSet');
0332 n = min(length(x), nmin);
0333 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', x(1:n))));
0334 x = x(n+1:end);
0335 elc.appendChild(elcc);
0336 end
0337
0338 x = d.f;
0339 nmin = getappdata(0, 'xmlsetsize');
0340 while ~isempty(x)
0341 elcc = xml.docNode.createElement('XSet');
0342 n = min(length(x), nmin);
0343 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', x(1:n))));
0344 x = x(n+1:end);
0345 elc.appendChild(elcc);
0346 end
0347 el.appendChild(elc);
0348 else
0349
0350 elc = xml.docNode.createElement('dType');
0351 elc.appendChild(xml.docNode.createTextNode('complex'));
0352 el.appendChild(elc);
0353
0354
0355 elc = xml.docNode.createElement('Data');
0356 x = d.xx;
0357 nmin = getappdata(0, 'xmlsetsize');
0358 while ~isempty(x)
0359 n = min(length(x), nmin);
0360 elcc = xml.docNode.createElement('rYSet');
0361 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', real(x(1:n)))));
0362 elc.appendChild(elcc);
0363 elcc = xml.docNode.createElement('iYSet');
0364 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', imag(x(1:n)))));
0365 elc.appendChild(elcc);
0366 x = x(n+1:end);
0367 end
0368
0369 x = d.f;
0370 nmin = getappdata(0, 'xmlsetsize');
0371 while ~isempty(x)
0372 elcc = xml.docNode.createElement('XSet');
0373 n = min(length(x), nmin);
0374 elcc.appendChild(xml.docNode.createTextNode(sprintf('%20.20g ', x(1:n))));
0375 x = x(n+1:end);
0376 elc.appendChild(elcc);
0377 end
0378 el.appendChild(elc);
0379 end
0380
0381 else
0382 error('### unknown data type.');
0383 end
0384 xml.docRootNode.appendChild(el);
0385
0386
0387