How to save an app property to an .m file?

6 ビュー (過去 30 日間)
Josh Drake
Josh Drake 2022 年 6 月 29 日
コメント済み: Josh Drake 2022 年 6 月 29 日
I'm working on an app in App Designer and have created a public property that is assigned a folder path as a char. The path can be edited/changed via an edit field and needs to be saved to a file for future reference, however, when I try to save I recieve an error saying the property is not a scalar structure. I test the property to confirm it is a structure and is scalar, which give results of 1. So, I'm confused what is wrong.
app.dataPaths.projectFolder = app.ProjectFolderEditField.Value;
app.ProjectFolderLabel.Text = '';
st = isstruct(app.dataPaths);
sc = isscalar(app.dataPaths);
% Save the new dataPath variable
save('StartUpPathData.mat','-struct','app.dataPaths');
Any help or suggestions are appreciated.

採用された回答

Walter Roberson
Walter Roberson 2022 年 6 月 29 日
When you save() with -struct then the name that you give must be the name of a full variable.
That is, copy app.dataPaths to a variable and save the variable.
  1 件のコメント
Josh Drake
Josh Drake 2022 年 6 月 29 日
That worked, thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by