Function related to Event Listener not found
1 view (last 30 days)
Show older comments
Hi all,
I have a simulink model (.slx file) and a gui (.mlapp file created with App Designer). They are located into the same folder. I added the following code to the StartFcn of the simulink model
h = add_exec_event_listener('blockDiagram/mySubSys', 'PostOutputs', @gui.myFunc);
and I defined a function, called myFunc, into the gui file, in this way
methods (Access = public)
function myFunc(block, ~)
% code
end
end
Unfortunately, when I run the model, the Command Window displays the following error
Undefined function 'gui.myFunc' for input arguments of type 'Simulink.RunTimeBlock'.
So, how can I solve this problem ?
Thank you for reading.
0 Comments
Answers (1)
Walter Roberson
on 29 Jun 2017
Perhaps
h = add_exec_event_listener('blockDiagram/mySubSys', 'PostOutputs', @(varargin) gui.myFunc);
or
h = add_exec_event_listener('blockDiagram/mySubSys', 'PostOutputs', @(varargin) myFunc(gui));
See Also
Categories
Find more on Event Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!