assign parameter values with sim command

Suppose I have a Simulink model called myModel.mdl. One of the blocks has a parameter, and I have assigned to it the variable:
sfreq
If I want to set this variable to 0.5 and run the model, then the following code suffices:
sfreq=0.5;
sim('myModel')
However for reasons too complicated to explain here, I would like to make the first command part of the second. If sfreq were a MODEL parameter then I would simply do the following:
sim('myModel','sfreq','0.5')
Unfortunately sfreq is a block parameter, and so I get back the following error:
block_diagram does not have a parameter named 'sfreq'
Any ideas for avoiding this error?
Thanks!

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 7월 19일
편집: Azzi Abdelmalek 2013년 7월 19일

0 개 추천

Use set_param function

댓글 수: 2

Azzi,
Thank you for the suggestion. That command is exactly what I tried first. Unfortunately I won't always have access to the parameter name, which is apparently required for set_param. I can automatically find the BLOCKS in which the parameter appears by using the following command:
blocks=find_system('blockDialogParams','sfreq')
But I cannot actually find the NAMES of the parameters in the blocks which are set to the variable sfreq.
You can get the name of your parameter by
get_param('yourmodel/yourblockName', 'Dialogparameters')

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Modeling에 대해 자세히 알아보기

태그

질문:

Ben
2013년 7월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by