Save Structure to .mat-file in dialog via GUI

6 ビュー (過去 30 日間)
Dominik Müller
Dominik Müller 2020 年 10 月 8 日
コメント済み: Dominik Müller 2020 年 10 月 8 日
Hi everyone,
I have a GUI made in app designer in which I create a large structure with a lot of data. I now want to export/save the structure by klicking a button. This button should open a dialog in which the user is able to create a new file or to overwrite an existing file.
uisave();
and
struct = uisetfile;
are not working.
uisave() doesn't work with a structure and uisetfile requires an already existing file to write to. Is there a way to simply take that structure and write it in a .mat-file? It's not necessary to save as .mat but I think to afterwards load the data it would be the easiest way to save as .mat?!

採用された回答

Stephen23
Stephen23 2020 年 10 月 8 日
S = .. your big structure
[F,P] = uiputfile('*.mat');
save(fullfile(P,F),'-struct','S') % if S is scalar
save(fullfile(P,F),'S') % if S is non-scalar
Don't forget when loading it is strongly recommended to load into an output variable:
S = load(..)
  3 件のコメント
Rik
Rik 2020 年 10 月 8 日
You should first make it a separate variable:
S = app.S;
[F,P] = uiputfile('*.mat');
save(fullfile(P,F),'-struct','S') % if S is scalar
save(fullfile(P,F),'S') % if S is non-scalar
Dominik Müller
Dominik Müller 2020 年 10 月 8 日
Thanks a lot! Now it works perfectly!!!!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by