フィルターのクリア

Problem with getting output from KeyPressFcn

3 ビュー (過去 30 日間)
yuval
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
set(h,'KeyPressFcn',{@pushbutton_callback,var1,var2});
function outputVar = pushbutton_callback(src,event,var1,var2)
outputVar = var1*var2;
end
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
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 );
end
Then it can be accessed via
hGUIData = guidata( h )
hGUIData.outputVar

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

回答 (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