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.m,v 1.7 2007/08/26 12:01: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.m,v 1.7 2007/08/26 12:01: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.x)) ' 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 %     data.x = data.x';
0043 %     data.y = data.y';
0044 
0045   case 'complex'
0046 
0047     disp('-- reading complex data samples');
0048 
0049     data.x = [];
0050     ry     = [];
0051     iy     = [];
0052 
0053     children = node.getChildNodes;
0054     for j=1:children.getLength
0055       ch = children.item(j-1);
0056       nodeName = char(ch.getNodeName);
0057 
0058       switch nodeName
0059         case 'XSet'
0060           vals = str2num(char(ch.getTextContent));
0061           data.x = [data.x vals];
0062           disp(['* read ' num2str(length(data.x)) ' X samples']);
0063         case 'rYSet'
0064           vals = str2num(char(ch.getTextContent));
0065           ry = [ry vals];
0066           disp(['* read ' num2str(length(ry)) ' real Y samples']);
0067         case 'iYSet'
0068           vals = str2num(char(ch.getTextContent));
0069           iy = [iy vals];
0070           disp(['* read ' num2str(length(iy)) ' imag Y samples']);
0071         otherwise
0072           %       warning(['!!! unknown data sample child node.' nodeName]);
0073       end
0074     end
0075 
0076 %     data.x = data.x';
0077 %     ry     = ry';
0078 %     iy     = iy';
0079 
0080     data.y = complex(ry, iy);
0081 
0082   otherwise
0083     error('### unknown data type.');
0084 end
0085 
0086 
0087 % END
0088

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003