⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 createobjective.m

📁 国外专家做的求解LMI鲁棒控制的工具箱,可以相对高效的解决LMI问题
💻 M
字号:
function [c,Q,f,onlyfeasible] = createobjective(h,G,options,quad_info)
%CREATEOBJECTIVE Internal function to extract data related to objective function

% Author Johan L鰂berg
% $Id: createobjective.m,v 1.5 2005/03/22 12:32:34 joloef Exp $


onlyfeasible = 0;
nvars = yalmip('nvars'); 
if isempty(h)
    c=zeros(nvars,1);
    Q = spalloc(nvars,nvars,0);
    f = 0;
    if isempty(G)
        onlyfeasible = 1;
    end
else  
    [n,m]=size(h);
    if n*m>1
        error('Scalar expression to minimize please.');
    else
        % Should check quadratic!!
        if ~options.relax & ~isempty(quad_info)
            Qh = quad_info.Q;
            ch = quad_info.c;
            f = quad_info.f;
            xvar = quad_info.x;
            lmi_variables = getvariables(xvar);
            c = zeros(nvars,1);
            Q = spalloc(nvars,nvars,0); 
            for i=1:length(lmi_variables)
                c(lmi_variables(i))=ch(i);
            end
            if nnz(Qh)>0
                % This has to be sped up... 
                for i = 1:length(lmi_variables)
                    for j = 1:length(lmi_variables)
                        Q(lmi_variables(i),lmi_variables(j))=Qh(i,j);
                    end
                end
            end
        else
            % A relaxed problem should not calculate quadratic
            % decomposistion, fix!
            c=zeros(nvars,1);
            lmi_variables = getvariables(h);
            base = getbase(h);base= base(2:end);
            c(lmi_variables) = base;
          %  for i=1:length(lmi_variables)
          %      c(lmi_variables(i))=getbasematrix(h,lmi_variables(i));
          %  end  
            Q = spalloc(nvars,nvars,0); 
            f = full(getbasematrix(h,0));
        end
    end
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -