フィルターのクリア

Matlab app - Using properites(app) opens another instance of the app

1 回表示 (過去 30 日間)
Thorne Hanna-Spain
Thorne Hanna-Spain 2023 年 10 月 2 日
コメント済み: Thorne Hanna-Spain 2023 年 10 月 2 日
Hello, I am trying to write a function that will save apps properties to a .mat file. To do this I have called properties(app) and then loop over these properties until I get the the properties I want to save. However, my function causes another window of the app to open. After some troubleshooting I realise that this occurs when properties(app) is called. my code is included below for clarity.
function savesimfile(app, filename, fileloc)
props = properties(QFM3);
savestate = 0
savestartmarker = 'SaveDataStart'
for iprop = 1:length(props)
ipropname = props{iprop}
if ipropname == savestartmarker
savestate = 1
elseif savestate == 1
disp(ipropname)
end
end
end
  3 件のコメント
Walter Roberson
Walter Roberson 2023 年 10 月 2 日
props = properties(QFM3);
Is QFM3 the name of the class? If so then that statement would be calling the class constructor.
Thorne Hanna-Spain
Thorne Hanna-Spain 2023 年 10 月 2 日
編集済み: Thorne Hanna-Spain 2023 年 10 月 2 日
Thanks for responding. I am new to matlab app design and classes in general. QFM3 is the name of the app and the name of the 'primary' class. My variables are stored in properties of this class alongside other properties matlab app uses to construct the app gui. Is there a way to just access this properties? I have included code to help discribe this structure below:
classdef QFM3 < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
FileMenu matlab.ui.container.Menu
...
end
properties (Access = public)
% my properties
SaveDataStart = 0
SimFileName = '' %Simulation File Name
...

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

採用された回答

Walter Roberson
Walter Roberson 2023 年 10 月 2 日
Change
props = properties(QFM3);
to
props = properties(app);
This assumes that savesimfile is a method of class QFM3.
  1 件のコメント
Thorne Hanna-Spain
Thorne Hanna-Spain 2023 年 10 月 2 日
Hi Walter. Thank you this solution it works perfectly!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by