Home > classes > @ao > private > xml_read_datasamples.m

xml_read_datasamples

PURPOSE ^

XML_READ_DATASAMPLES read data samples from the given node of an XML file.

SYNOPSIS ^

function data = xml_read_datasamples(node, dType)

DESCRIPTION ^

 XML_READ_DATASAMPLES read data samples from the given node of an XML file.
 
 M Hewitson 19-02-07
 
 $Id: xml_read_datasamples.html,v 1.1 2007/06/08 14:15:04 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function data = xml_read_datasamples(node, dType)
0002 
0003 % XML_READ_DATASAMPLES read data samples from the given node of an XML file.
0004 %
0005 % M Hewitson 19-02-07
0006 %
0007 % $Id: xml_read_datasamples.html,v 1.1 2007/06/08 14:15:04 hewitson Exp $
0008 %
0009 
0010 %          <Sample>
0011 %             <x>0</x>
0012 %             <y>27.1346</y>
0013 %          </Sample>
0014 
0015 switch dType
0016   case 'real'
0017     
0018     disp('-- reading real data samples');
0019 
0020     data.x = [];
0021     data.y = [];
0022 
0023     children = node.getChildNodes;
0024     for j=1:children.getLength
0025       ch = children.item(j-1);
0026       nodeName = char(ch.getNodeName);
0027 
0028       switch nodeName
0029         case 'XSet'
0030           vals = str2num(char(ch.getTextContent));
0031           data.x = [data.x vals];
0032           disp(['* read ' num2str(length(data.y)) ' X samples']);
0033         case 'YSet'
0034           vals = str2num(char(ch.getTextContent));
0035           data.y = [data.y vals];
0036           disp(['* read ' num2str(length(data.y)) ' Y samples']);
0037         otherwise
0038           %       warning(['!!! unknown data sample child node.' nodeName]);
0039       end
0040     end
0041     
0042   case 'complex'
0043     
0044     disp('-- reading complex data samples');
0045 
0046     data.x = [];
0047     ry     = [];
0048     iy     = [];
0049 
0050     children = node.getChildNodes;
0051     for j=1:children.getLength
0052       ch = children.item(j-1);
0053       nodeName = char(ch.getNodeName);
0054 
0055       switch nodeName
0056         case 'XSet'
0057           vals = str2num(char(ch.getTextContent));
0058           data.x = [data.x vals];
0059           disp(['* read ' num2str(length(data.x)) ' X samples']);
0060         case 'rYSet'
0061           vals = str2num(char(ch.getTextContent));
0062           ry = [ry vals];
0063           disp(['* read ' num2str(length(ry)) ' real Y samples']);
0064         case 'iYSet'
0065           vals = str2num(char(ch.getTextContent));
0066           iy = [iy vals];
0067           disp(['* read ' num2str(length(iy)) ' imag Y samples']);
0068         otherwise
0069           %       warning(['!!! unknown data sample child node.' nodeName]);
0070       end
0071     end
0072     
0073     data.y = complex(ry, iy);
0074     
0075   otherwise
0076     error('### unknown data type.');
0077 end
0078 
0079 
0080 % END
0081

Generated on Fri 08-Jun-2007 16:09:11 by m2html © 2003