Changing Simulink Real-Time Workspace Variable

I am currently working on Simulink Real Time (with Speedgoat). I want to change some variables in Model Workspace, from outside Speedgoat (using UDP connection or Serial Port).
I can't use assignin because it is not supported for code generation. Is it possible to do this?

Antworten (1)

Jonas
Jonas am 9 Mär. 2020

0 Stimmen

You should use the command setparam. Typical command is: setparam(tg,'speed_setpoint',100) for changing parameter 'speed_setpoint' on your target tg = slrt.

4 Kommentare

I am also running Simulink Real Time deployed onto a SpeedGoat. When I try set_param the error 'Cannot change parameter Constant value while simulation is running' is displayed.
It works fine when I run the simualtion (CTRL T) just on the machine. When i run the model via the Real-Time run tab I get the error above.
Jonas
Jonas am 18 Jan. 2022
Try setparam, not set_param. It is a different command.
Thank you Jonas. I can now edit tunable params during running :). I am using a GUI (matlab app) to alter the inputs into the model ad hoc. Is setparam the only method of driving the realtime model using the GUI?
Jonas
Jonas am 18 Jan. 2022
setparam is a direct way, and until recently the only way to build a MATLAB App that interfaces with a SLRT application.
With the recent update to SLRT, I believe they have expanded the way you can interface with a SLRT application. An alternative way now would be to use Instrumentation.
I have no experience with it but it should be a more convenient way of reading signals and displaying them on elements, and changing parameters without having to manually program it all.
For displaying a real-time graph, I used to program capturing of signals linked to a timer object to refresh the graph in a MATLAB App, but they made it more user-friendly from what I understand.

Melden Sie sich an, um zu kommentieren.

Produkte

Version

R2019b

Gefragt:

am 9 Mär. 2020

Kommentiert:

am 18 Jan. 2022

Community Treasure Hunt

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

Start Hunting!

Translated by