天天看点

matlab下生成的矩阵存入xml文件中

参考:http://blog.csdn.net/wzy1990/article/details/8508662

 % name是输入的文件名,data是matlab中的矩阵

function createxml(name,datatest)

xdoc=com.mathworks.xml.XMLUtils.createDocument('opencv_storage');  

xroot=xdoc.getDocumentElement;  

%  

[m,n]=size(datatest);  

type=xdoc.createElement(name);  

xroot.appendChild(type);  

type.setAttribute('type_id','opencv-matrix')  

%  

rows=xdoc.createElement('rows');  

rows.appendChild(xdoc.createTextNode(sprintf('