Get parameter value from named parameter in Simulink in Simulink Real-time

조회 수: 23 (최근 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!

채택된 답변

Diego Kuratli
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:
  댓글 수: 1
Jonas
Jonas 2019년 11월 15일
Oh I feel stupid. It is indeed setparam that I am using to set a parameter value, and should use getparam for reading the value. It works fine! I was mixing up with the set_param and get_param commands.
Or maybe I should not be so hard on myself and realise that the commands are confusing and easily mixed up...
Thanks for the help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Target Computer Setup에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by