Function related to Event Listener not found
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Walter Roberson
2017 年 6 月 29 日
Perhaps
h = add_exec_event_listener('blockDiagram/mySubSys', 'PostOutputs', @(varargin) gui.myFunc);
or
h = add_exec_event_listener('blockDiagram/mySubSys', 'PostOutputs', @(varargin) myFunc(gui));
参考
カテゴリ
Help Center および File Exchange で Event Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!