Efficient update of MATLAB App Designer real-time GUI from Simulink

I have a Simulink model and GUI created in the application designer from which I manipulate the specified model. Until now, I was able to let the GUI and Simulink models exchange in both directions. The GUI sets up constant blocks of constants in the model with set_param

, while the model updates the GUI through a callback with add_exec_event_listener

. The GUI object is on the model stage.

In the callback when starting the model StartFcn

, I have the following code

set(0,'ShowHiddenHandles','on');
blk = [model '/q-log']; % Block to bind listener to
event = 'PostOutputs'; % Event to bind to (fired at every sample)
app = getVariable(get_param(bdroot,'ModelWorkspace'),'app'); % The GUI

% The GUI is passed into the event handler and updated at every timestep
listener = @(obj,event) updategui(obj,event,app); 
h = add_exec_event_listener(blk, event, listener);

      

The problem with this setting is that it is very slow. I'm not really sure how to get it faster, and if that's the way to go. I've looked at many examples, but none of my details need it.

So my question is, is there a faster or more efficient way to update GUI fields and graphs? It doesn't have to be hard real-time, but writing variables to the workspace and importing it into the GUI afterwards isn't acceptable.

+3


source to share





All Articles