to receive data from simulink and send to app designer
38 views (last 30 days)
Show older comments
i am working on app designer. i have built an application through app designer . Now i want to receive data from simulink model in real time to update my app designer editfield. i dont know how to do this . please if somebody can help me in this issue. THANKS
0 Comments
Answers (1)
Luca Ferro
on 21 Feb 2023
Edited: Luca Ferro
on 27 Feb 2023
one option would be to have some to workspace blocks in the simulink file: Log data to workspace from Simulink model - Simulink - MathWorks Switzerland. You just connect them to the signal you want to log and upon simulation it will put the in the workspace in the format you choose (array, timeseries, struct,...).
Now you can store them in a variable and so update the app.
In pseudocode:
%let's say you placed a 'to workspace' block that gives you a struct 'out' with 3 signals 'a,b,c'
out=sim(<slxFileName>); %simulates and logs the signals in a variable
updateApp = plot (out.tout,out.a); %tout is the time of the simulation and will be logged in the struct automatically
The plot is just a simple example, you should use the now logged values in app functions as you prefer.
2 Comments
Luca Ferro
on 27 Feb 2023
this is the simulink side:
let's say you want the this saturated ramp to log it on your app for some reason.
the 'to workspace' block on the bottom right corner will output the ramp array (and the simulation time) to a struct in the matlab workspace upon simulation (see code in the previous answer). From there, since they are stored in an accessible variable, you can use their values to update you app.
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!