How can I stream a fixed-step signal to MATLAB and retune a Gain parameter live (no pause) in Simulink R2024b?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MATLAB / Simulink version: R2024b
Solver: Fixed-step (ode4), FixedStep = 1e-4
Goal
-----
1. While my model is running, view (or log) every sample of a signal that is written to a Data Store Memory at the 100 µs rate.
2. At any moment, update a controller gain K from MATLAB (or a Dashboard knob) so the new value is used by the Gain block in the *very next* solver step.
3. Do all of this without pausing or stopping the simulation—just one click on **Run** in MATLAB and everything works in “real time”.
What I have tried
-----------------
* **To Workspace** block → only writes at the end of the run.
* **RuntimeObject** on the Data Store Read probe → polling in a `while` loop misses most samples unless I step the simulation manually.
* **Data Access Callback** on the probe signal → works, but pushing 10 kHz samples into the base workspace with `assignin` feels heavy; not sure if this is the recommended way.
Questions
---------
1. What is the *official / best-practice* mechanism in R2024b to stream a fixed-step signal (1 e-4 s) to MATLAB while the model is running?
2. Is the Data Access Callback approach the right tool, or is there something better (e.g., SDI API, External Mode, XCP)?
3. Any minimal example or doc reference that shows both (a) live signal access per step and (b) live gain update without pausing would be greatly appreciated.
Model sketch (very simple)
--------------------------
[Sine Wave] --> [Gain (Gain = K)] --> [Data Store Write]
|
[Data Store Memory sharedDSM]
|
[Data Store Read] --> Terminator (probe for logging)
--------------------
Thank you!
1 Kommentar
Paul
am 18 Mai 2025
1. While my model is running, view (or log) every sample of a signal that is written to a Data Store Memory at the 100 µs rate.
What is the source of the signal that is being written to the Data Store Memory block?
Why is the signal being written to the Data Store Memory block?
2. At any moment, update a controller gain K from MATLAB (or a Dashboard knob) so the new value is used by the Gain block in the *very next* solver step.
What is the relationship between the signal being written to the Data Story Memory and value of the controller gain K?
Antworten (0)
Siehe auch
Kategorien
Mehr zu Event Functions finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!