Define max and min of tunable parameters using SYSTUNE in Simulink

조회 수: 1 (최근 30일)
Stakis93
Stakis93 2016년 12월 20일
답변: Stakis93 2016년 12월 21일
I'm trying to optimize the gain K of my Simulink model using Systune, which looks like the model below. I precise that I'm using the r2013b version of Matlab/Simulink. My problem is to define the max and min values of K reachable in the optimization process.
For the moment, after initializing the value of K, I've tried this :
st0 = slTunable('model','K');
K = getBlockParam(st0,'K');
K.Gain.Maximum = K_max;
K.Gain.Minimum = K_min;
Then I've defined some soft and hard requirements and then I call the systune function.
[st1,fsoft,gHard,Info] = systune(st0,req_soft,req_hard);
It is compiling but after verifying the optimized value of K, it does not respect my bounds K_man and K_min. Indeed, when we type :
st0.getBlockParam('K').Gain.Maximum
st0.getBlockParam('K').Gain.Minimum
we obtain +Inf and -Inf, respectively, which are the default values...
I tried also simply to type
st0.getBlockParam('Ks').Gain.Maximum = K_max;
But this returns the error "No public field getBlockParam exists for class slTunable."
I saw that it is done pretty easy when using Systune in Matlab only thks to the ltiblock.gain class but when we want to interface with Simulink, things are getting harder due to the slTunable class.
Thank you for your help !

채택된 답변

Stakis93
Stakis93 2016년 12월 21일
Found my answer ! To access the properties of the ltiblock (in my example it is a ltiblock.gain), as maximum and minimum reachable values, you have to create an ltiblock parameterized as you need and then use the setBlockParam function. This could be done like this for my example :
st0 = slTunable('model','K'); % Definition of the interface between Simulink and Matlab for Systune
K_wanted = ltiblock.gain('K',Ny,Nu); % Def of a tunable gain with Ny outputs and Nu inputs
K_wanted.Gain.Maximum = K_max;
K_wanted.Gain.Minimum = K_min;
st0.setBlockParam('K',K_wanted);
This last lign changes the default parameterization of K into the parameterization defined by the ltiblock.gain K_wanted which contains the bounds. We can verify that with :
st0.getBlockParam('K').Gain.Maximum
% or
st1.getBlockParam('K').Gain.Minimum
It is not really a straightforward solution but at least it works !

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Gain Scheduling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by