Cost function to minimize variance of error

조회 수: 4 (최근 30일)
Rishabh Pachchhao
Rishabh Pachchhao 2022년 10월 31일
답변: Sam Chak 2022년 10월 31일
I need to design a cost function to minimize the variance of error input to my controller in order to find out optimum values of my controller parameters. I have the transfer function of my plant and my reference signal is a constant 0. My controller is a simple lead lag filter with a gain. How do I design a cost function for this task?

답변 (1개)

Sam Chak
Sam Chak 2022년 10월 31일
Since you didn't provide info about your system. here is an example that you can study. However, I don't think that miniming the error variance works.
In the example, if you let , then the variance .
k0 = 1;
k = fminunc(@costfun, k0)
Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance.
k = 532.3080
s = tf('s');
Gp = 1/(s*(s + 5)*(s + 10));
Gc = k*((s + 4)*(s + 0.1))/((s + 7.3)*(s + 0.01));
Gcl = feedback(Gc*Gp, 1);
t = linspace(0, 10, 1001);
step(Gcl, t)
function J = costfun(k)
s = tf('s');
Gp = 1/(s*(s + 5)*(s + 10));
Gc = k*((s + 4)*(s + 0.1))/((s + 7.3)*(s + 0.01));
Gcl = feedback(Gc*Gp, 1);
t = linspace(0, 10, 1001);
y = step(Gcl, t);
err = 1 - y;
% J = var(err);
J = trapz(t, err.^2);
end

카테고리

Help CenterFile Exchange에서 Pole and Zero Locations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by