What Does Each Element of This Syntax Mean?

조회 수: 1 (최근 30일)
Rightia Rollmann
Rightia Rollmann 2017년 3월 26일
댓글: Jan 2017년 3월 27일
I create a push button in GUIDE. When I create a callback function for it, it automatically creates the syntax below:
Could you please explain what each element of this syntax mean?

채택된 답변

Jan
Jan 2017년 3월 26일
  1. @() means the creation of an anonymous function.
  2. @(hObject, eventdata) is an anoynmous function with 2 inputs.
  3. The body of this anonymous function is
PushButton('pushbutton1_Callback', hObject, eventdata, guidata(hObject))
  1. (Dull formatting in th forum, this is 4.!) This means, that the function "PushButton" is called with the 2 inputs of the anonymous function and as 3rd input the current value of the handles struct is obatined from the figure.
To reduce the levels of indirection and for simplicity this might be a valid callback also:
@pushbutton1_Callback
with this definition of the function:
function pushbutton1_Callback(hObject, eventdata)
handles = guidata(hObject);
...
  댓글 수: 2
Rightia Rollmann
Rightia Rollmann 2017년 3월 26일
Thanks! Could you give me another example (preferably, an example that can be run as a script) of such code? I am stilling struggling with its syntax.
Jan
Jan 2017년 3월 27일

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by