how to save 1x3072 data without output truncated error?

3 ビュー (過去 30 日間)
Darlling5147 Sew
Darlling5147 Sew 2013 年 10 月 7 日
回答済み: Ronit 2025 年 6 月 11 日
I am facing problem of extracting a data of 1*3072 into xml file. The last data can be saved is no.2500. Output truncated error occurred ever since there. Can anybody help? Here is my code:
docNode = com.mathworks.xml.XMLUtils.createDocument('LUT'); xmlwrite(docNode) entry_node = docNode.createElement('sigmaLUT');
a= signal(:,1); b= abs(a)';
entry_node.appendChild(docNode.createTextNode(sprintf('%i',b))); docNode.getDocumentElement.appendChild(entry_node); xmlwrite(docNode) xmlwrite('sigmaLUT.xml',docNode);

回答 (1 件)

Ronit
Ronit 2025 年 6 月 11 日
Hello,
You should split the data into multiple smaller XML elements or chunks rather than trying to dump all values into a single TextNode. Refer to the following example to write in chunks:
chunkSize = 500;
docNode = com.mathworks.xml.XMLUtils.createDocument('LUT');
rootNode = docNode.getDocumentElement;
entry_node = docNode.createElement('sigmaLUT');
for i = 1:chunkSize:length(b)
chunk = b(i:min(i+chunkSize-1, end));
chunkNode = docNode.createElement('chunk');
chunkNode.appendChild(docNode.createTextNode(sprintf('%i ', chunk)));
entry_node.appendChild(chunkNode);
end
rootNode.appendChild(entry_node);
xmlwrite('sigmaLUT.xml', docNode);
I hope this helps with your query!

カテゴリ

Help Center および File ExchangeStructured Data and XML Documents についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by