Get parameter value from named parameter in Simulink in Simulink Real-time
22 次查看(过去 30 天)
显示 更早的评论
Hi all
I am running a Simulink model using Simulink Real-time on a SpeedGoat target. I am using Simulink Parameters inside a Data Dictionary. I can easily change the value of these Simulink Parameters defined in the Data Dictionary by using the command set_param(tg,'Ki_speed',2), which will change the value of parameter 'Ki_speed' to 2 running in real-time on my target 'tg'. I really like this approach since I can use the parameter name anywhere in my model - also inside model referenced - and it has immediate effect.
I am now looking to also request the parameter value of the named Simulink Parameter, instead of setting it. I have tried get_param(tg,'Ki_speed') but it throws the error:
The first input to get_param must be of type 'double', 'char' or 'cell'.
When I request get_param('tg','Ki_speed') I get the error:
Invalid Simulink object name: tg
Caused by:
No block diagram 'tg' is loaded.
I have also tried get_param(0,'Ki_speed') but it throws
block_diagram does not have a parameter named 'Ki_speed'
I don't know how to do use this command in this situation, or don't know if it can be used for this purpose at all. Does anyone know? Thanks!
0 个评论
采纳的回答
Diego Kuratli
2019-11-14
For reading and writing parameters during real-time execution, you can use the following functions:
getparam(tg, 'Ki_speed')
setparam(tg, 'Ki_speed', 2)
See:
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Target Computer Setup 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!