How to change number precision with writestruct
6 ビュー (過去 30 日間)
古いコメントを表示
The number of significant digits of writestruct is quite limited, as showed by this example
s=struct('pi',pi);
writestruct(s,'pi.xml');
type pi.xml
Does anyone know how to change/control/increase it?
採用された回答
Scott MacKenzie
2021 年 5 月 14 日
編集済み: Scott MacKenzie
2021 年 5 月 14 日
s=struct('pi', num2str(pi, 15)); % pi with 15 significant figures
writestruct(s, 'pi.xml');
type pi.xml
Output:
<?xml version="1.0" encoding="UTF-8"?>
<struct>
<pi>3.141592653589793</pi>
</struct>
4 件のコメント
Scott MacKenzie
2021 年 5 月 16 日
Yes, I see your point. I studied the documentation and clearly writestruct is not intended for numeric variables. The focus is on text, and xml in particular. Good luck.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!