Home > classes > @pzmodel > private > fromxml.m

fromxml

PURPOSE ^

FROMXML read from part of an XML tree and create a pzmodel object.

SYNOPSIS ^

function po = fromxml(xml)

DESCRIPTION ^

 FROMXML read from part of an XML tree and create a pzmodel object.
 
 M Hewitson 28-08-07 
 
 $Id:$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function po = fromxml(xml)
0002 
0003 % FROMXML read from part of an XML tree and create a pzmodel object.
0004 %
0005 % M Hewitson 28-08-07
0006 %
0007 % $Id:$
0008 %
0009 
0010 
0011 % disp('---------------- pzmodel ------------------')
0012 % xml.getNodeName
0013 % disp('---------------- pzmodel ------------------')
0014 
0015 % default
0016 p.name  = '';
0017 p.poles = [];
0018 p.zeros = [];
0019 p.gain  = 0;
0020 
0021 sch = xml.getChildNodes;
0022 for c=1:sch.getLength
0023   x = sch.item(c-1);
0024   switch char(x.getNodeName)
0025     case 'name'
0026       p.name = char(x.getTextContent);
0027     case 'gain'
0028       p.gain = str2num(char(x.getTextContent));
0029     case 'poles'
0030       p.poles = [];
0031       xch = x.getChildNodes;
0032       for j=1:xch.getLength
0033         it = xch.item(j-1);
0034         if strcmp(char(it.getNodeName), 'pole')
0035           p.poles = [p.poles pole(it)];
0036         end
0037       end
0038     case 'zeros'
0039       p.zeros = [];
0040       xch = x.getChildNodes;
0041       for j=1:xch.getLength
0042         it = xch.item(j-1);
0043         if strcmp(char(it.getNodeName), 'zero')
0044           p.zeros = [p.zeros zero(it)];
0045         end
0046       end
0047     otherwise
0048   end
0049 end
0050 
0051 % build pzmodel
0052 po = pzmodel(p.gain, p.poles, p.zeros, p.name);
0053 
0054 % END

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