フィルターのクリア

How do I use uicontrol to assign a value to a variable?

19 ビュー (過去 30 日間)
Marcus Blackburn
Marcus Blackburn 2017 年 3 月 27 日
回答済み: Nanda Gupta 2017 年 3 月 29 日
If i have a uicontrol pushbutton, how do I make it so that when a button is depressed, it changes the value of a variable? Just change something like k = 'somestring' or some number, to 'someotherstring' or some other number.
  2 件のコメント
Jan
Jan 2017 年 3 月 27 日
It depends on where this variable is existing: Do you mean the base workspace, a diagram, a Simulink object, a function, a MAT file?
Marcus Blackburn
Marcus Blackburn 2017 年 3 月 27 日
A base workspace. Just change something like k = 'somestring' or some number, to 'someotherstring' or some other number.

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

採用された回答

Nanda Gupta
Nanda Gupta 2017 年 3 月 29 日
I understand that you want to change the value of a variable in the base workspace when a button is pressed.
This can be done by using callback functions for the respective components, in this case a "push button". For example, after creating the uicontrol pushbutton, a callback function can be defined like:
function pushbutton1_Callback(hObject, eventdata, handles)
if(k == "somestring")
k = "someotherstring";
For more information regarding "callback functions", you can refer to:
Also, the uicontrol components such as "pushbutton" can be created using the "uicontrol" function and an appropriate callback function can be associated with it using the "Callback" property. For more information regarding this, please refer: http://www.mathworks.com/help/matlab/ref/uicontrol.html

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by