to receive data from simulink and send to app designer

9 次查看(过去 30 天)
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

回答(1 个)

Luca Ferro
Luca Ferro 2023-2-21
编辑:Luca Ferro 2023-2-27
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 个评论
Luca Ferro
Luca Ferro 2023-2-27
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by