How can I pass variable for to m-file when push button is pressed?

조회 수: 2 (최근 30일)
Teemu Juujärvi
Teemu Juujärvi 2015년 9월 21일
댓글: Stephen23 2015년 9월 23일
Hi,
I have stop button at my GUI and if the stop button is pressed I want to pass a variable to m-file, how can do that? I have stop_flag=0 in m-file, but if stop button is pressed from the GUI then stop_flag should be 1 in m-file.
Teemu

답변 (1개)

Stephen23
Stephen23 2015년 9월 21일
편집: Stephen23 2015년 9월 21일
Here are the documents showing how to pass arguments between callbacks and functions:
If you want an example of this, take a look at my FEX submission cubhelix_view:
This function create a figure with a "demo" button: pressing this turn the demo on and off. It is based on a loop like this:
function chvDemo(tgh,~)
while ishghandle(tgh)&&get(tgh,'Value')
% loop code here
end
end
and is called from the button like this:
uicontrol(figH, 'Style','togglebutton', 'Max',1, 'Min',0, 'Callback',@chvDemo);
  댓글 수: 2
Teemu Juujärvi
Teemu Juujärvi 2015년 9월 22일
Does this work when I make GUI with guide-tool? Because I wonder what I have to put pushbutton callback and what to m-file? I can get pushbutton handle as matlab.graphics.GraphicsPlaceholder and then I can't get information from it. What I do wrong? Teemu
Stephen23
Stephen23 2015년 9월 23일
I have never used GUIDE as I prefer to program things myself. I have no idea what is required.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by