필터 지우기
필터 지우기

How to change Simulink constant block value to a constant variable?

조회 수: 84 (최근 30일)
Sumin
Sumin 2014년 6월 10일
댓글: sherif Gad 2021년 11월 12일
Hello,
I'm trying to find a way to set constant value in constant block in Simulink to a constant variable. Namely, I want to set the constant value to g*c/3. g and c values are optimized by fmincon and determined.
In MATLAB, I tried to write something like
>> set_param([simfilename '/Constant2'],'Constant value',num2str(gc/3));
The constant block in Simulink has been named as "Constant2".
What I'm trying to achieve is to have this constant block output different numerical outputs according to g and c values determined by fmincon.
Thank you.

채택된 답변

Kaustubha Govind
Kaustubha Govind 2014년 6월 12일
set_param([simfilename '/Constant2'],'Value', num2str(gc/3));

추가 답변 (1개)

Sumin
Sumin 2014년 6월 12일
Thanks Kaustubha,
I actually had to put * between g and c as well. So this worked,
set_param([simfilename '/Constant2'],'Value',num2str(g*c/3));
Sumin

카테고리

Help CenterFile Exchange에서 General Applications에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by