You can access the signal data using "add_exec_event_listener":
"add_exec_event_listener" registers a listener for a block method execution event and returns a handle to the listener that it registered. For details on how to use this function, please refer to the following documentation.
Below is an example code that displays the data of signal 'x1' in the Edit Field. Please refer to the attached app file (example.mlapp).
function updateApp(app, block, event)
app.EditField.Value = block.OutputPort(1).Data;
end
function StartButtonPushed(app, event)
set_param(app.ModelName,'SimulationCommand','start')
app.Listener = add_exec_event_listener([app.ModelName '/x1'],'PostOutputs',@app.updateApp);
end
If you want to access bus data composed of multiple elements, refer to the code below. Please refer to the other attached app file (example_bus.zip).
function updateApp(app, block, event)
app.EditField.Value = block.OutputPort(1).Data.x1;
app.EditField_2.Value = block.OutputPort(1).Data.x2;
end
function StartButtonPushed(app, event)
set_param(app.ModelName,'SimulationCommand','start')
app.Listener = add_exec_event_listener([app.ModelName '/Bus Creator'],'PostOutputs',@app.updateApp);
end
Please note this API and using set_param/get_param to change block parameters is not supported in app deployment. If you eventually have the goal to deploy your app to a standalone executable, you will need to get Simulink Compiler and use the Simulink Compiler APIs for accessing signal data and modifying block parameters.