I have. You can access public app designer functions with coder.extrinsic. You first have to create the functions in App Designer. Then you create a handle in Simulink/Stateflow. My initialise block looks like this:
initialise
% initialise app and import the apps interface
en: coder.extrinsic('gia_app', 'update_clock', 'update_sample1', 'update_sample2', 'update_position1', 'update_position2' ,'update_display', 'update_finished'); %'update_temp9', 'update_temp10', 'update_temp11')
app = gia_app();
(This is written in a stateflow chart. I do not know how to implement it in Simulink without the use of Stateflow.)
-"app" is the handle i create -"gia_app" is the name of my app designer file -everything except "gia_app" behind "coder.extrinsic" is a public function in the app designer file
The functions can now be called in Stateflow. example:
update_display(app, message)
You can even pass variables, like in this case message. The public function "update_display" has exactly one input argument. This is the app designer code of the function:
function results = update_display(app, input)
% 0 = start
% 1 = change pos of sample1
% 2 = change pos of sample2
% 3 = spectate sample1
% 4 = spectate sample2
% 5 = mix
% 6 = waiting
%
if input == 0
new_line = 'Prozessstart';
...
Important Note: If you want to pass variables from App Designer to the running Simulink-Simulation, you will probably save them in the Matlab base-workspace. Simulink does not update the Variables automatically, while the simulation is running!!! Whenever you change a variable in App Designer or generally somewhere outside of the running Simulink-Simulation, you have to pause, update and continue the simulation. (This will not notice the pausing, this is all done in very short time). example:
set_param('gia_sim' ,'SimulationCommand','pause'); % pause simulation, so variables can be read
assignin('base', 'pres11', value);
set_param('gia_sim','SimulationCommand','update'); % update app with new variable
set_param('gia_sim','SimulationCommand','continue');
Hope I could help you. If you have more questions I would be happy to help. Im pretty busy myself right now though, so it could take some time.
1 Comment
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/375472-how-to-use-handles-to-connect-app-designer-and-simulink-with-each-other#comment_551690
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/375472-how-to-use-handles-to-connect-app-designer-and-simulink-with-each-other#comment_551690
Sign in to comment.