input live data (continuously generated data) from app designer to simulink
22 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I am trying to calculate state of charge using simulink block diagrams. My current and voltage adc values are gotten from a serial port and sent to app designer to get the actual current and voltage. I am trying to get this values to simulink.
I have tried using "assignin" to send the variables to the work space and then read them from there, but the variables are not updateing. The simulink model reads the first values and stops. After I stop the app, the work space then updates to the lates value.
I wish to ask how I can get this running with variables flowing from app designer to simulink and updating as required?
Thanks
0 Kommentare
Antworten (1)
Animesh
am 12 Jun. 2023
As per my understanding you want to share a continuously changing variable in your app designer to your simulink model.
You can do so by using the "From Workspace" block in your simulink model.
Steps to do so are as follows:
1. Declare the variables that you want to share as global in your app designer. You can do so by including the following line of code at the beginning of your app designer function or in the startupFcn.
'global variablename'
2. Set the value of the global variable in your MATLAB App Designer function.
function updateVariable(app, new_value)
global variablename
variablename = new_value;
end
3. Add a 'From Workspace' block in your simulink model. You can add this block from 'Sources' library of simulink.
4. In the 'From Workspace' block parameters, set the 'Data' field to the name of the global variable that was declared in app designer.
5.Connect the 'From workspace' block to rest of your simulink model as needed.
Now, when you run your MATLAB app designer and the value of your global variable is updated, it will be reflected in simulink.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!