Filter löschen
Filter löschen

Unexpected number of function input arguments

1 Ansicht (letzte 30 Tage)
KAE
KAE am 9 Jun. 2017
Bearbeitet: KAE am 9 Jun. 2017
I am confused by "extra" function inputs in the program GUI_27 from the file exchange. Can you help me figure out where they come from? Here's the relevant lines,
% Here we pass in 1 argument, S, to a function accessed by the handle @fh_wbmfcn.
set(S.fh,'windowbuttonmotionfcn',{@fh_wbmfcn,S})
% Here is the start of function fh_wbmfcn which receives 1 argument in the line above
function [] = fh_wbmfcn(varargin)
% Yet when I put a breakpoint at this point to check, there were 3 inputs!
% varargin{1} is a handle to a figure that fh_wbmfcn will access, which we didn't pass in above
% varargin{2} is mouse data within that figure, which we didn't pass in above
S = varargin{3}; % The third argument is the structure S passed in above
I am confused why 3 inputs appear within fh_wbmfcn when it seems we only passed in 1 input. How did the other 2 inputs get in there?
  1 Kommentar
KAE
KAE am 9 Jun. 2017
Bearbeitet: KAE am 9 Jun. 2017
Walter's answer here indicates that these 2 additional inputs are expected because this is a graphics object callback. I do not know how to give him credit for the fact that his answer addressed the present question, but will leave this question up since it might help someone. If instead I should delete it, please let me know.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by