MATLAB: Plotting in a GUI in RTW

embedded matlabguiplotrtw

Hello everyone.
I've written an 'Embedded MATLAB Function' that allows me to plot realtime data from a Simulink model in a GUI (which I created in GUIDE).
function flag = fcn(x, y)
%#eml
eml.extrinsic('plot', 'findobj');
axesHandles = findobj('Type', 'axes', 'Tag', 'axTrack');
plot(axesHandles, x, y, 'b-');
flag = 0;
This code works without any problems when I just run simulations.
As soon as I try this within RTW, it doesn't work anymore. While RTW was running, I tried to plot a point on my GUI with the same syntax, but from the Command Window
axesHandles = findobj('Type', 'axes', 'Tag', 'axTrack');
plot(axesHandles, 0, 0, 'b+', 'MarkerSize', 10);
and it worked.
Does somebody know how to make it work in the EMF?
Thank you in advance.
Francesco

Best Answer

I solved the problem using event listeners.