Function related to Event Listener not found

1 visualización (últimos 30 días)
tahec
tahec el 28 de Jun. de 2017
Editada: tahec el 29 de Jun. de 2017
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.

Respuestas (1)

Walter Roberson
Walter Roberson el 29 de Jun. de 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));
  1 comentario
tahec
tahec el 29 de Jun. de 2017
Hi, thank you for your reply. When I use the first expression, MATLAB says me
The class gui has no Constant property or Static method named 'myFunc'.
Error in gui>@(varargin)gui.myFunc
When I use the second expression, MATLAB opens several windows of my GUI, but it doesn't print any error message.
However, App Designer suggests that I have to "use app as the first argument for myFunc". But the result is the same.

Iniciar sesión para comentar.

Categorías

Más información sobre Event Functions en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by