Dynamic-Calibration/utils/YALMIP-master/modules/global/computecost.m

12 lines
349 B
Mathematica
Raw Normal View History

2019-12-18 11:25:45 +00:00
function cost = computecost(f,c,Q,x,p);
cost = f+c'*x+x'*Q*x;
if ~isequal(p.K.m,0)
top = size(p.F_struc,1)-sum(p.K.m.^2)+1;
for i = 1:length(p.K.m)
X = p.F_struc(top:top + p.K.m(i)^2-1,:)*[1;x];
X = reshape(X,p.K.m(i),p.K.m(i));
cost = cost - sum(real(log(real(eig(X)))));
top = top + p.K.m(i)^2;
end
end