Callback functions: more than 2 input arguments

조회 수: 5 (최근 30일)
Fiona
Fiona 2013년 3월 28일
Hi, attempting my first GUI and am wondering if it is possible to add extra input arguments into a callback function.
Typically you just have hObject,eventdata. I want to add 3 variables from my workspace, how do I do that from the command: set(buttonsY,'SelectionChangeFcn',@yvar_Callback)
Thanks in advance, fiona
  댓글 수: 1
Image Analyst
Image Analyst 2013년 3월 28일
There is no master workspace like there is with a simple script. Each function has its own private workspace. You can make variables global with the global keyword and then every function that declares that variable global will be able to see it - no passing via the argument list is needed. They would rather that you use getappdata() and setappdata() though.

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

답변 (1개)

Image Analyst
Image Analyst 2013년 3월 28일
Yes, but you shouldn't need to. Why don't you follow the methods in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F

카테고리

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