I'm trying to count the number of times the gui is being run on clicking a pushbutton. How to make the count continue even after the application is closed and started again. (i.e) if the count is 8 before closing ,it should start from 9 the next time

2 ビュー (過去 30 日間)
I'm setting up the counter variables in the pushbutton callback and set the user data while the gui loads. \\before gui loads
set(handles.btnRun,'UserData',0)
\\PushButton CallBack
counter = get(hObject, 'UserData') + 1;
set(hObject, 'UserData', counter);
// As we are setting it to 0 , it is starting from 0 everytime. How to define a global varibale or something which can pass the previous count. //
Thanks for the help.

採用された回答

Jan Orwat
Jan Orwat 2016 年 10 月 5 日
You may specify delete function which will be called each time application/gui is closed. Using this you may save all the variables you want to the file. Then using creation function you can bring those variables back. Read more about figure properties.
  2 件のコメント
Pavan Seeram
Pavan Seeram 2016 年 10 月 5 日
Thanks for the answer.Can we specify this function to the close button which comes by default in the gui. Or can we write a seperate function.
Jan Orwat
Jan Orwat 2016 年 10 月 6 日
編集済み: Jan Orwat 2016 年 10 月 6 日
Write your own function, then specify it as a callback, for example DeleteFcn in gui figure. It will be called when one close the app. You can do it via button as well.

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by