readstruct/writestruct changes boolean value true to "true"
显示 更早的评论
Hello,
I am working on a MATLAB app at the moment. Some user controllable settings need to be preserved over restarting the app. During runtime these settings (statuses of buttons, text areas and checkboxes) are saved in a struct. On exiting the app, the struct is written to the hard drive of the PC using the function writestruct.
On startup, the app is loading the created XML file using readstruct. However, the values of the checkboxes (either logical true or false) are not read/saved correctly. Logical values are converted to strings.
Code example for reading/writing the struct to xml:
Write:
file = uiputfile('\Path\to\File\*.xml','Save');
writestruct(app.Settings,file,"FileType","xml");
Read:
file = uigetfile('\Path\to\File\*.xml');
app.Settings = readstruct(file,"FileType","xml");
While debugging, I tried to restore the settings during runtime with the generated struct, which worked as intended.
Thank you for your help!
I attached the generated XML file as an M file because I'm not allowed to upload files with the XML extension…
1 个评论
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Standard File Formats 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!