Aufgrund einer Wartung wird GitLab am 29.10. zwischen 9:00 und 10:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 29.10. between 9:00 and 10:00 am.

Aufgrund einer Konfigurationsänderung wird die GitLab Registry ab 10 Uhr nur Read Only zur Verfügung stehen. / Due to a configuration change, the GitLab Registry will be available for read-only access from 10am.

getDocNode.m 3.41 KB
Newer Older
Jan-Gerrit Richter's avatar
Jan-Gerrit Richter committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
function docNode = getDocNode(transFunc, inputImp, bsName)

xml = getXMLStrings();

docNode = com.mathworks.xml.XMLUtils.createDocument(xml.DocType);
docRootNode = docNode.getDocumentElement;
% docRootNode.setAttribute('attr_name','attr_value');

versionNode = docNode.createElement(xml.Version);
versionNode.appendChild...
    (docNode.createTextNode(xml.ActualVersion));
docRootNode.appendChild(versionNode);

mainNode = docNode.createElement(xml.SaveTypeQuadripole);
docRootNode.appendChild(mainNode);


quadMSNode = getQuadripoleMSNode(docNode, transFunc, inputImp, bsName);
mainNode.appendChild(quadMSNode);



function quadMSNode = getQuadripoleMSNode(docNode, transFunc, inputImp, bsName)

xml = getXMLStrings();

quadMSNode = docNode.createElement(xml.QuadripoleMeasured);

optionsNode = getOptionsNode(docNode, bsName);
[freqVecNode, transferFunctionNode, inputImpedanceNode] = lsData2DomNodes(docNode, transFunc, inputImp);

quadMSNode.appendChild(optionsNode);
quadMSNode.appendChild(freqVecNode);
quadMSNode.appendChild(transferFunctionNode);
quadMSNode.appendChild(inputImpedanceNode);


function optionsNode = getOptionsNode(docNode, bsName)

xml = getXMLStrings();

optionsNode = docNode.createElement(xml.Options);
nameNode = docNode.createElement(xml.Name);
nameNode.appendChild(docNode.createTextNode(bsName));
optionsNode.appendChild(nameNode);


function [freqVecNode, transferFunctionNode, inputImpedanceNode] = lsData2DomNodes(docNode, transFunc, inputImp)

fVec = transFunc.freqVector;
fVec2 = inputImp.freqVector;

if ~areIdenticalFreqVecs(fVec, fVec2)
    error('Data files have no identical frequency vectors!')
%     ita_interpolate_spk()
end

transFunc = transFunc.freqData;
inputImp = inputImp.freqData;

freqVecNode = getFreqVecNode(docNode, fVec);
transferFunctionNode = getTransferFunctionNode(docNode, transFunc);
inputImpedanceNode = getInputImpedanceNode(docNode, inputImp);

function str = realArray2str(array)
str = mat2str(array);
str = strrep(str, '[', '');
str = strrep(str, ']', '');
str = strrep(str, ' ', ',');
str = strrep(str, ';', ',');

function [strReal, strImag] = cmplxArray2str(cmplxArray)

strReal = realArray2str(real(cmplxArray));
strImag = realArray2str(imag(cmplxArray));

function bool = areIdenticalFreqVecs(fVec1, fVec2)
bool = isequal(fVec1, fVec2);

function freqVecNode = getFreqVecNode(docNode, freqVec)
xml = getXMLStrings();

freqVecNode = docNode.createElement(xml.FrequencyList);
strFreqVec = realArray2str(freqVec);
freqVecNode.appendChild(docNode.createTextNode(strFreqVec));


function transferFunctionNode = getTransferFunctionNode(docNode, transFunc)
xml = getXMLStrings();
transferFunctionNode = docNode.createElement(xml.TransferFunction);

[realNode, imagNode] = getRealAndImagNode(docNode, transFunc);
transferFunctionNode.appendChild(realNode);
transferFunctionNode.appendChild(imagNode);

function inputImpNode = getInputImpedanceNode(docNode, inputImp)
xml = getXMLStrings();
inputImpNode = docNode.createElement(xml.InputImpedance);

[realNode, imagNode] = getRealAndImagNode(docNode, inputImp);
inputImpNode.appendChild(realNode);
inputImpNode.appendChild(imagNode);

function [realNode, imagNode] = getRealAndImagNode(docNode, cmplxArray)
xml = getXMLStrings();

realNode = docNode.createElement(xml.Real);
imagNode = docNode.createElement(xml.Imag);

[strReal, strImag] = cmplxArray2str(cmplxArray);

realNode.appendChild(docNode.createTextNode(strReal));
imagNode.appendChild(docNode.createTextNode(strImag));