Cost function to minimize variance of error
4 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
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)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Pole and Zero Locations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
