필터 지우기
필터 지우기

Error in Using set_param

조회 수: 16 (최근 30일)
William
William 2014년 7월 14일
댓글: Fuli Wang 2019년 12월 13일
I've not been able to set the consant in the "constant" block. I used: set_param('dummy/Constant','x',50) but kept getting eroor "Constant block does not have a parameter named 'x'". 'dummy' is the model name.
Thanks.

채택된 답변

William
William 2014년 7월 14일
I still got error: "Invalid setting in Constant block 'Constant' for parameter 'Value'. 'x' is in the place of the 'constant' block where the numeric value is given.
  댓글 수: 5
William
William 2014년 7월 15일
how can I replace the constant value with a variable (x in this case) & set x to the value I want? Thanks (I got with it worked with your suggestion above).
Brian B
Brian B 2014년 7월 15일
If x is a variable in the workspace, then you can use
set_param('dummy/Constant','Value','x')

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

추가 답변 (1개)

Brian B
Brian B 2014년 7월 14일
Try
set_param('dummy/Constant','Value','50')
Note that the value is also a string.
  댓글 수: 4
William
William 2014년 7월 15일
how can I replace the constant value with a variable (x in this case) & set x to the value I want? Thanks.
Fuli Wang
Fuli Wang 2019년 12월 13일
x=50;
set_param('untitled/Constant','Value',num2str(x));

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

카테고리

Help CenterFile Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by