Effacer les filtres
Effacer les filtres

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

76 vues (au cours des 30 derniers jours)
Sumin
Sumin le 10 Juin 2014
Commenté : sherif Gad le 12 Nov 2021
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.

Réponse acceptée

Kaustubha Govind
Kaustubha Govind le 12 Juin 2014
set_param([simfilename '/Constant2'],'Value', num2str(gc/3));

Plus de réponses (1)

Sumin
Sumin le 12 Juin 2014
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

Catégories

En savoir plus sur General Applications dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by