hello
I create a button in my figure and I want when I pushe the button it returns value of 1 in to a variable. I wrote this code but I couldn't get the Output Value.
f = figure;
ax.Position = [75 75 325 280];
c = uicontrol('Style','pushbutton','Callback',@(src,event)BinSet);
function Output=BinSet
Output=1;
disp('successfull')
end

 採用された回答

Rik
Rik 2020 年 4 月 30 日

0 投票

Callback functions ignore output variables. If you want to do something with a value outside of the callback you need to store it elsewhere: the guidata, the appdata (setappdata and getappdata), or preferences (getpref and setpref).
For more advice about how to work with GUIs you can read the documentation or find helpful links here.

2 件のコメント

Mohamad Marjani
Mohamad Marjani 2020 年 4 月 30 日
thank you, I didn't work with this before can you tell me how use this in my code?
Rik
Rik 2020 年 4 月 30 日
I highly encourage you to read the documentation for each of these functions and to check out the discussion I linked. The doc will explain how to use those functions, the thread will explain how to choose which you should use.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStartup and Shutdown についてさらに検索

質問済み:

2020 年 4 月 30 日

コメント済み:

Rik
2020 年 4 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by