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

📄 assign.m

📁 国外专家做的求解LMI鲁棒控制的工具箱,可以相对高效的解决LMI问题
💻 M
字号:
function assign(X,value,ls)
%ASSIGN Assigns a numerical value to an sdpvar
%
% ASSIGN(X,value)   Tries to set the free variables in X so that  
%                   double(X)=value. Notice that other variables
%                   sharing the same free variables will be affected.
%                   If the assignment is infeasible, an error message
%                   will be issued.
%
% ASSIGN(X,value,1) Least square assignment.

% Author Johan L鰂berg 
% $Id: assign.m,v 1.2 2005/05/31 16:08:22 joloef Exp $  

if nargin<3
    ls = 0;
end

if ~isa(X,'sdpvar')
    error('First argument should be an SDPVAR object.');
end

if ~isa(value,'double')
    error('Second argument should be a DOUBLE.');
end

if ~isequal(size(X),size(value))
  error('Both arguments must have same size') 
end
if ~isa(X,'sdpvar')
  error('First arguments must be an sdpvar object') 
end

x_lmi_variables = X.lmi_variables;
b = value(:)-X.basis(:,1);
A = X.basis(:,2:end);
feas_var = A\b;
% Improve
e = A*feas_var-b;
de = A\e;
feas_var = feas_var-de;

if ~ls
    if norm(A*feas_var-b)>sqrt(eps)
        error('Inconsistent assignment')
    end
end

sol = yalmip('getsolution');
keep_these = find(~ismember(sol.variables,x_lmi_variables));
sol.optvar = [sol.optvar(keep_these);feas_var(:)];
sol.variables = [sol.variables(keep_these);x_lmi_variables(:)];
yalmip('setallsolution',sol);



⌨️ 快捷键说明

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