MATLAB Answers

How to access to data in the simulink in real time

77 ビュー (過去 30 日間)
Mohamed El Koujok
Mohamed El Koujok 2019 年 7 月 25 日
回答済み: Sara Nadeau 2019 年 7 月 26 日
Hi all,
When I run the simulink, I must wait until the end of the run to have acces to the data.
I want to access to the data at each iteration
Can you help ?
Thank you

  0 件のコメント

サインインしてコメントする。

回答 (3 件)

Sara Nadeau
Sara Nadeau 2019 年 7 月 25 日
Hi Mohamed,
Could you clarify what you mean by 'data at each iteration' and describe what you want to do with the data? Also, what release are you using?
If you'd like to view data during simulation, you likely have some options.
Sara

  0 件のコメント

サインインしてコメントする。


Mohamed El Koujok
Mohamed El Koujok 2019 年 7 月 26 日
I am using Matlab 2019a.
I have a chemical process with several variables (pressure, temperature, concentration, etc.)
In Simulink, the only way to have access to the values of the variables (pressure, temperature, setpoint) is the workspace. But I should wait until the end of the run ( for example 1 hours) to get access to the values of these variables from the workspace. I would like to get the values in real-time and use them in another application.
I hope that I explained my problem better than before.
Thank you,
Mohamed

  0 件のコメント

サインインしてコメントする。


Sara Nadeau
Sara Nadeau 2019 年 7 月 26 日
This doesn't exactly allow you access to your data in real-time, but you can use a Data Access callback function to access packets of data for a logged signal during the simulation. You write the code for the callback function in an m-file and then specify the function name and inputs the function expects in the Instrumentation Properties for the signal. After you mark a signal for logging, you can access the instrumentation properties by right-clicking the logging badge and selecting Properties.
You can use the same callback function for multiple signals, or specify a unique callback function for each logged signal.
For details, here is a simple example from the documentation: Access Data in a MATLAB Function During Simulation.
I hope this helps!

  0 件のコメント

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by