I am trying to create a GUI in App Designer that will display values from a Simulink model. Using the add_exec_event_listener I am able to get the GUI to change the value of a numeric EditField based on the model. The problem is that every time the value changes and the GUI should update, it just opens up a new figure that has the new value. It doesn't just change the existing figure to match the new value, which is what I want it to do. I have looked around quite a bit but cannot seem to find anyone else that has posted this problem or anything similar.
My current simulink model is just a constant going to a display box (it will be far more complicated, but this is just for me to sovle this problem). My Simulink model callbacks are:
blk = 'Trial1/DisplayBox';
event = 'PostOutputs';
listener = @(app,event) updateGUI(TrialApp1);
h = add_exec_event_listener(blk,event,listener);
My updateGUI function in App Designer is written as:
methods (Access = public)
rto = get_param([bdroot,'/DisplayBox'],'RuntimeObject');
app.EditField.Value = rto.InputPort(1).Data
I am guessing that the issue lies with how I have my model callbacks written in the Simulink model, but I am really not sure. This format seems to match multiple other places and asnwers that I have found but it seems I have made a mistake somewhere.