Optimizing simulink parameters from matlab code

조회 수: 11 (최근 30일)
Jasmin Falconer
Jasmin Falconer 2022년 11월 21일
댓글: Jasmin Falconer 2023년 1월 23일
I have a simulink simulation that I am trying to optimize, however the gains (gain a,b,c etc) are calculated outside of simulink using matlab code before running the simulation.
For example if you want to run the simulation, you first go to the matlab code to calculate all the parameters:
In the matlab script one might enter:
Q=12000
f=24000
and from that the gains are calculated in the matlab script to be:
a=1/Q
b=f*Q
etc
I would like to optimize the values of Q and f rather than the gains a,b,c. However, when I optimize, my only options are things that are directly in the simulink code: a,b,c etc. How can I optimize the output of my model via changing Q and f?
Thanks!
  댓글 수: 2
Sai
Sai 2022년 11월 24일
Hi Jasmin,
Can you please send me the model and code so that I could also try from my end?
Jasmin Falconer
Jasmin Falconer 2023년 1월 23일
Apoliges for the very delayed response. What is the best way for me to send you the model? I have attached a simplified version of the model and the associated matlab script. I would like to be able to optimize the matlab file parameters in order to maximize the simulink model outputs and then read the output from the simulink.

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

답변 (1개)

Sam Chak
Sam Chak 2022년 11월 25일
Put it another way around, you can fminunc() to directly optimize the gains from the Simulink model and then probably solve for Q and f from the optimal gains using fsolve().
Else, if the MATLAB script is simple enough that it consists of some straightforward static equations like
a = fun1(Q, f)
b = fun2(Q, f)
c = fun3(Q, f)
then you can describe that in the Simulink model using the fundamental blocks, and use fminunc() to optimize Q and f.

카테고리

Help CenterFile Exchange에서 Manual Performance Optimization에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by