Problem with getting output from KeyPressFcn

조회 수: 5 (최근 30일)
yuval . 2018년 2월 9일
댓글: Adam . 2018년 2월 9일
Hello, I have a KeyPressFcn with two input variables and i would like one output variable.
Example of the code:
h = figure
function outputVar = pushbutton_callback(src,event,var1,var2)
outputVar = var1*var2;
The problem is that outputVar doesn't exist in the workspace afterwards...
I've read the documentation but still as it appears didn't really understand how to work with this function.
Thanks in advance.
  댓글 수: 1
Adam 2018년 2월 9일
Callbacks cannot define output arguments. You will need to save your value using e.g. guidata:
function pushbutton_callback(src,event,var1,var2)
hGUIData = guidata( src );
hGUIData.outputVar = var1*var2;
guidata( src, hGUIData );
Then it can be accessed via
hGUIData = guidata( h )

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

답변 (0개)


Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기


Community Treasure Hunt

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

Start Hunting!

Translated by