If it's not possible, this must be candidate for a frustration thread
How to change number precision with writestruct
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Bruno Luong
le 14 Mai 2021
Commenté : Scott MacKenzie
le 16 Mai 2021
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?
Réponse acceptée
Scott MacKenzie
le 14 Mai 2021
Modifié(e) : Scott MacKenzie
le 14 Mai 2021
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 commentaires
Scott MacKenzie
le 16 Mai 2021
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Structures dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!