Mercurial > hg > ltpda
view m-toolbox/classes/+utils/@xml/attachMatrixToDom.m @ 52:daf4eab1a51e database-connection-manager tip
Fix. Default password should be [] not an empty string
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 07 Dec 2011 17:29:47 +0100 |
parents | f0afece42f48 |
children |
line wrap: on
line source
function attachMatrixToDom(numbers, dom, parent) shape = sprintf('%dx%d', size(numbers)); % REMARK: It is not possible to name the type 'matrix' because 'matrix' % is also a class name. %%%%% Real data %%%%% realNode = dom.createElement('realData'); realNode.setAttribute('type', 'doubleMatrix'); realNode.setAttribute('shape', shape); %%% Set the parent attribute 'type' to doubleMatrix parent.setAttribute('type', 'doubleMatrix'); parent.appendChild(realNode); for ii = 1:size(numbers,1) number_str = strtrim(utils.xml.num2str(real(numbers(ii,:)))); if ~isempty(number_str) %%% Create new matrix node content = dom.createTextNode(number_str); matrixNode = dom.createElement('doubleMatrix'); matrixNode.setAttribute('type', class(numbers)); matrixNode.appendChild(content); realNode.appendChild(matrixNode); end end %%%%% Imaginary data %%%%% if ~isreal(numbers) imagNode = dom.createElement('imagData'); imagNode.setAttribute('type', 'doubleMatrix'); imagNode.setAttribute('shape', shape); parent.appendChild(imagNode); for ii = 1:size(numbers,1) number_str = strtrim(utils.helper.num2str(imag(numbers(ii,:)))); if ~isempty(number_str) %%% Create new matrix node content = dom.createTextNode(number_str); matrixNode = dom.createElement('doubleMatrix'); matrixNode.setAttribute('type', class(numbers)); matrixNode.appendChild(content); imagNode.appendChild(matrixNode); end end end end