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(ltpda_mat2str(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('nsecs');
0046 elc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(d.nsecs)));
0047 el.appendChild(elc);
0048
0049
0050 xml = xml_add_time(xml, get(d, 't0'), 't0', el);
0051
0052
0053 elc = xml.docNode.createElement('Version');
0054 elc.appendChild(xml.docNode.createTextNode(d.version));
0055 el.appendChild(elc);
0056
0057
0058 xml = xml_add_time(xml, get(d, 'created'), 'created', el);
0059
0060 if isreal(d.x)
0061
0062
0063 elc = xml.docNode.createElement('dType');
0064 elc.appendChild(xml.docNode.createTextNode('real'));
0065 el.appendChild(elc);
0066
0067
0068 elc = xml.docNode.createElement('Data');
0069 x = d.x;
0070 nmin = getappdata(0, 'xmlsetsize');
0071 while ~isempty(x)
0072 elcc = xml.docNode.createElement('YSet');
0073 n = min(length(x), nmin);
0074 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(x(1:n))));
0075 x = x(n+1:end);
0076 elc.appendChild(elcc);
0077 end
0078
0079 x = d.t;
0080 nmin = getappdata(0, 'xmlsetsize');
0081 while ~isempty(x)
0082 elcc = xml.docNode.createElement('XSet');
0083 n = min(length(x), nmin);
0084 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(x(1:n))));
0085 x = x(n+1:end);
0086 elc.appendChild(elcc);
0087 end
0088 el.appendChild(elc);
0089 else
0090
0091 elc = xml.docNode.createElement('dType');
0092 elc.appendChild(xml.docNode.createTextNode('complex'));
0093 el.appendChild(elc);
0094
0095
0096 elc = xml.docNode.createElement('Data');
0097 x = d.x;
0098 nmin = getappdata(0, 'xmlsetsize');
0099 while ~isempty(x)
0100 n = min(length(x), nmin);
0101 elcc = xml.docNode.createElement('rYSet');
0102 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(real(x(1:n)))));
0103 elc.appendChild(elcc);
0104 elcc = xml.docNode.createElement('iYSet');
0105 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(imag(x(1:n)))));
0106 elc.appendChild(elcc);
0107 x = x(n+1:end);
0108 end
0109
0110 x = d.t;
0111 nmin = getappdata(0, 'xmlsetsize');
0112 while ~isempty(x)
0113 elcc = xml.docNode.createElement('XSet');
0114 n = min(length(x), nmin);
0115 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(x(1:n))));
0116 x = x(n+1:end);
0117 elc.appendChild(elcc);
0118 end
0119 el.appendChild(elc);
0120 end
0121
0122
0123
0124 elseif isa(d, 'xydata')
0125
0126
0127
0128 elc = xml.docNode.createElement('Type');
0129 elc.appendChild(xml.docNode.createTextNode('xydata'));
0130 el.appendChild(elc);
0131
0132
0133 elc = xml.docNode.createElement('Name');
0134 elc.appendChild(xml.docNode.createTextNode(d.name));
0135 el.appendChild(elc);
0136
0137
0138 elc = xml.docNode.createElement('Xunits');
0139 elc.appendChild(xml.docNode.createTextNode(d.xunits));
0140 el.appendChild(elc);
0141
0142
0143 elc = xml.docNode.createElement('Yunits');
0144 elc.appendChild(xml.docNode.createTextNode(d.yunits));
0145 el.appendChild(elc);
0146
0147
0148 elc = xml.docNode.createElement('Version');
0149 elc.appendChild(xml.docNode.createTextNode(d.version));
0150 el.appendChild(elc);
0151
0152
0153 xml = xml_add_time(xml, get(d, 'created'), 'created', el);
0154
0155 if isreal(d.y)
0156
0157 elc = xml.docNode.createElement('dType');
0158 elc.appendChild(xml.docNode.createTextNode('real'));
0159 el.appendChild(elc);
0160
0161
0162 elc = xml.docNode.createElement('Data');
0163 x = d.x;
0164 nmin = getappdata(0, 'xmlsetsize');
0165 while ~isempty(x)
0166 elcc = xml.docNode.createElement('XSet');
0167 n = min(length(x), nmin);
0168 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(x(1:n))));
0169 x = x(n+1:end);
0170 elc.appendChild(elcc);
0171 end
0172
0173 y = d.y;
0174 nmin = getappdata(0, 'xmlsetsize');
0175 while ~isempty(y)
0176 elcc = xml.docNode.createElement('YSet');
0177 n = min(length(y), nmin);
0178 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(y(1:n))));
0179 y = y(n+1:end);
0180 elc.appendChild(elcc);
0181 end
0182 el.appendChild(elc);
0183 else
0184
0185 elc = xml.docNode.createElement('dType');
0186 elc.appendChild(xml.docNode.createTextNode('complex'));
0187 el.appendChild(elc);
0188
0189
0190 elc = xml.docNode.createElement('Data');
0191 y = d.y;
0192 nmin = getappdata(0, 'xmlsetsize');
0193 while ~isempty(y)
0194 n = min(length(y), nmin);
0195 elcc = xml.docNode.createElement('rYSet');
0196 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(real(y(1:n)))));
0197 elc.appendChild(elcc);
0198 elcc = xml.docNode.createElement('iYSet');
0199 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(imag(y(1:n)))));
0200 elc.appendChild(elcc);
0201 y = y(n+1:end);
0202 end
0203
0204 x = d.x;
0205 nmin = getappdata(0, 'xmlsetsize');
0206 while ~isempty(x)
0207 elcc = xml.docNode.createElement('XSet');
0208 n = min(length(x), nmin);
0209 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(x(1:n))));
0210 x = x(n+1:end);
0211 elc.appendChild(elcc);
0212 end
0213 el.appendChild(elc);
0214 end
0215
0216
0217
0218 elseif isa(d, 'cdata')
0219
0220 elc = xml.docNode.createElement('Type');
0221 elc.appendChild(xml.docNode.createTextNode('cdata'));
0222 el.appendChild(elc);
0223
0224
0225 elc = xml.docNode.createElement('Name');
0226 elc.appendChild(xml.docNode.createTextNode(d.name));
0227 el.appendChild(elc);
0228
0229
0230 elc = xml.docNode.createElement('Xunits');
0231 elc.appendChild(xml.docNode.createTextNode(d.xunits));
0232 el.appendChild(elc);
0233
0234
0235 elc = xml.docNode.createElement('Yunits');
0236 elc.appendChild(xml.docNode.createTextNode(d.yunits));
0237 el.appendChild(elc);
0238
0239
0240 elc = xml.docNode.createElement('Version');
0241 elc.appendChild(xml.docNode.createTextNode(d.version));
0242 el.appendChild(elc);
0243
0244
0245 xml = xml_add_time(xml, get(d, 'created'), 'created', el);
0246
0247
0248 elc = xml.docNode.createElement('Tags');
0249 tags = get(d, 'tags');
0250 istr = '';
0251 for j=1:length(tags)
0252 istr = [istr ' ' tags{j}];
0253 end
0254 elc.appendChild(xml.docNode.createTextNode(istr));
0255 el.appendChild(elc);
0256
0257
0258 elc = xml.docNode.createElement('Shape');
0259 elc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(size(d.vals))));
0260 el.appendChild(elc);
0261
0262 if isreal(d.vals)
0263
0264 elc = xml.docNode.createElement('dType');
0265 elc.appendChild(xml.docNode.createTextNode('real'));
0266 el.appendChild(elc);
0267
0268
0269 elc = xml.docNode.createElement('Data');
0270 x = d.vals;
0271 nmin = getappdata(0, 'xmlsetsize');
0272 while ~isempty(x)
0273 elcc = xml.docNode.createElement('YSet');
0274 n = min(length(x), nmin);
0275 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(x(1:n))));
0276 x = x(n+1:end);
0277 elc.appendChild(elcc);
0278 end
0279 el.appendChild(elc);
0280 else
0281
0282 elc = xml.docNode.createElement('dType');
0283 elc.appendChild(xml.docNode.createTextNode('complex'));
0284 el.appendChild(elc);
0285
0286
0287 elc = xml.docNode.createElement('Data');
0288 x = d.vals;
0289 nmin = getappdata(0, 'xmlsetsize');
0290 while ~isempty(x)
0291 n = min(length(x), nmin);
0292 elcc = xml.docNode.createElement('rYSet');
0293 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(real(x(1:n)))));
0294 elc.appendChild(elcc);
0295 elcc = xml.docNode.createElement('iYSet');
0296 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(imag(x(1:n)))));
0297 elc.appendChild(elcc);
0298 x = x(n+1:end);
0299 end
0300 el.appendChild(elc);
0301 end
0302
0303
0304
0305 elseif isa(d, 'fsdata')
0306
0307
0308 elc = xml.docNode.createElement('Type');
0309 elc.appendChild(xml.docNode.createTextNode('fsdata'));
0310 el.appendChild(elc);
0311
0312
0313 elc = xml.docNode.createElement('Name');
0314 elc.appendChild(xml.docNode.createTextNode(d.name));
0315 el.appendChild(elc);
0316
0317
0318 elc = xml.docNode.createElement('Fs');
0319 elc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(d.fs)));
0320 el.appendChild(elc);
0321
0322
0323 elc = xml.docNode.createElement('ENBW');
0324 elc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(d.enbw)));
0325 el.appendChild(elc);
0326
0327
0328 elc = xml.docNode.createElement('Navs');
0329 elc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(d.navs)));
0330 el.appendChild(elc);
0331
0332
0333 elc = xml.docNode.createElement('Xunits');
0334 elc.appendChild(xml.docNode.createTextNode(d.xunits));
0335 el.appendChild(elc);
0336
0337
0338 elc = xml.docNode.createElement('Yunits');
0339 elc.appendChild(xml.docNode.createTextNode(d.yunits));
0340 el.appendChild(elc);
0341
0342
0343 elc = xml.docNode.createElement('Version');
0344 elc.appendChild(xml.docNode.createTextNode(d.version));
0345 el.appendChild(elc);
0346
0347
0348 xml = xml_add_time(xml, get(d, 'created'), 'created', el);
0349
0350 if isreal(d.xx)
0351
0352 elc = xml.docNode.createElement('dType');
0353 elc.appendChild(xml.docNode.createTextNode('real'));
0354 el.appendChild(elc);
0355
0356
0357 elc = xml.docNode.createElement('Data');
0358 x = d.xx;
0359 nmin = getappdata(0, 'xmlsetsize');
0360 while ~isempty(x)
0361 elcc = xml.docNode.createElement('YSet');
0362 n = min(length(x), nmin);
0363 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(x(1:n))));
0364 x = x(n+1:end);
0365 elc.appendChild(elcc);
0366 end
0367
0368 x = d.f;
0369 nmin = getappdata(0, 'xmlsetsize');
0370 while ~isempty(x)
0371 elcc = xml.docNode.createElement('XSet');
0372 n = min(length(x), nmin);
0373 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(x(1:n))));
0374 x = x(n+1:end);
0375 elc.appendChild(elcc);
0376 end
0377 el.appendChild(elc);
0378 else
0379
0380 elc = xml.docNode.createElement('dType');
0381 elc.appendChild(xml.docNode.createTextNode('complex'));
0382 el.appendChild(elc);
0383
0384
0385 elc = xml.docNode.createElement('Data');
0386 x = d.xx;
0387 nmin = getappdata(0, 'xmlsetsize');
0388 while ~isempty(x)
0389 n = min(length(x), nmin);
0390 elcc = xml.docNode.createElement('rYSet');
0391 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(real(x(1:n)))));
0392 elc.appendChild(elcc);
0393 elcc = xml.docNode.createElement('iYSet');
0394 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(imag(x(1:n)))));
0395 elc.appendChild(elcc);
0396 x = x(n+1:end);
0397 end
0398
0399 x = d.f;
0400 nmin = getappdata(0, 'xmlsetsize');
0401 while ~isempty(x)
0402 elcc = xml.docNode.createElement('XSet');
0403 n = min(length(x), nmin);
0404 elcc.appendChild(xml.docNode.createTextNode(ltpda_mat2str(x(1:n))));
0405 x = x(n+1:end);
0406 elc.appendChild(elcc);
0407 end
0408 el.appendChild(elc);
0409 end
0410
0411 else
0412 error('### unknown data type.');
0413 end
0414 xml.docRootNode.appendChild(el);
0415
0416
0417