Home > m > helper > ltpda_xml_read_datasamples.m

ltpda_xml_read_datasamples

PURPOSE ^

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

SYNOPSIS ^

function data = ltpda_xml_read_datasamples(node, dType)

DESCRIPTION ^

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

 M Hewitson 19-02-07

 $Id: ltpda_xml_read_datasamples.m,v 1.5 2007/10/26 14:39:54 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function data = ltpda_xml_read_datasamples(node, dType)
0002 
0003 % LTPDA_XML_READ_DATASAMPLES read data samples from the given node of an XML file.
0004 %
0005 % M Hewitson 19-02-07
0006 %
0007 % $Id: ltpda_xml_read_datasamples.m,v 1.5 2007/10/26 14:39:54 hewitson Exp $
0008 %
0009 
0010 
0011 
0012 switch dType
0013   case 'real'
0014 
0015     disp('-- reading real data samples');
0016 
0017     data.x = [];
0018     data.y = [];
0019 
0020     children = node.getChildNodes;
0021     for j=1:children.getLength
0022       ch = children.item(j-1);
0023       nodeName = char(ch.getNodeName);
0024       cont = char(ch.getTextContent);
0025       switch nodeName
0026         case 'xset'
0027           vals = sscanf(cont, '%g ');
0028           data.x = [data.x ; vals];
0029           disp(['* read ' num2str(length(data.x)) ' X samples']);
0030         case 'yset'
0031           vals = sscanf(cont, '%g ');
0032           data.y = [data.y  ; vals];
0033           disp(['* read ' num2str(length(data.y)) ' Y samples']);
0034         otherwise
0035           %       warning(['!!! unknown data sample child node.' nodeName]);
0036       end
0037     end
0038 
0039 %     data.x = data.x';
0040 %     data.y = data.y';
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       cont = char(ch.getTextContent);
0055       switch nodeName
0056         case 'xset'
0057           vals = sscanf(cont, '%f ');
0058           data.x = [data.x ; vals];
0059           disp(['* read ' num2str(length(data.x)) ' X samples']);
0060         case 'ryset'
0061           vals = sscanf(cont, '%f ');
0062           ry = [ry ; vals];
0063           disp(['* read ' num2str(length(ry)) ' real Y samples']);
0064         case 'iyset'
0065           vals = sscanf(cont, '%f ');
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.x = data.x';
0074 %     ry     = ry';
0075 %     iy     = iy';
0076 
0077     data.y = complex(ry, iy);
0078 
0079   otherwise
0080     error('### unknown data type.');
0081 end
0082 
0083 
0084 % END
0085

Generated on Mon 31-Mar-2008 13:54:54 by m2html © 2003