How to change number precision with writestruct

3 views (last 30 days)
The number of significant digits of writestruct is quite limited, as showed by this example
type pi.xml
<?xml version="1.0" encoding="UTF-8"?> <struct> <pi>3.1416</pi> </struct>
Does anyone know how to change/control/increase it?

Accepted Answer

Scott MacKenzie
Scott MacKenzie on 14 May 2021
Edited: Scott MacKenzie on 14 May 2021
s=struct('pi', num2str(pi, 15)); % pi with 15 significant figures
writestruct(s, 'pi.xml');
type pi.xml
<?xml version="1.0" encoding="UTF-8"?>
Scott MacKenzie
Scott MacKenzie on 16 May 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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!