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

📄 norm.m

📁 国外专家做的求解LMI鲁棒控制的工具箱,可以相对高效的解决LMI问题
💻 M
字号:
function varargout = norm(varargin)
%NORM (overloaded)
%
% t = NORM(x,P)
%
% The variable t can only be used in convexity preserving
% operations such as t<0, minimize t etc.
%
%    For matrices...
%      NORM(X) models the largest singular value of X, max(svd(X)).
%      NORM(X,2) is the same as NORM(X).
%      NORM(X,1) models the 1-norm of X, the largest column sum, max(sum(abs(X))).
%      NORM(X,inf) models the infinity norm of X, the largest row sum, max(sum(abs(X'))).
%      NORM(X,'fro') models the Frobenius norm, sqrt(sum(diag(X'*X))).
%    For vectors...
%      NORM(V) = norm(V,2) = standard Euclidean norm.
%      NORM(V,inf) = max(abs(V)).
%      NORM(V,1) = sum(abs(V))
 

% Author Johan L鰂berg 
% $Id: norm.m,v 1.10 2005/07/20 13:39:00 joloef Exp $


%% ***************************************************
% This file defines a nonlinear operator for YALMIP
%
% It can take three different inputs
% For double inputs, it returns standard double values
% For sdpvar inputs, it genreates a an internal variable
% When first input is 'model' it generates the epigraph

%% ***************************************************
switch class(varargin{1})

    case 'double' % What is the numerical value of this argument (needed for displays etc)
        % SHOULD NEVER HAPPEN, THIS SHOULD BE CAUGHT BY BUILT-IN
        error('Overloaded SDPVAR/NORM CALLED WITH DOUBLE. Report error')

    case 'sdpvar' % Overloaded operator for SDPVAR objects. Pass on args and save them.
        if nargin == 1
            varargout{1} = yalmip('addextendedvariable',mfilename,varargin{1},2);
        else
            switch varargin{2}
                case {1,2,inf,'fro'}
                    varargout{1} = yalmip('addextendedvariable',mfilename,varargin{:});
                otherwise
                    error('norm(x,P) only supported for P = 1,2,inf and ''fro''');
            end
        end

    case 'char' % YALMIP sends 'model' when it wants the epigraph or hypograph
        if isequal(varargin{1},'graph')
            t = varargin{2};
            X = varargin{3};
            p = varargin{4};
            switch p
                case 1
                    z = sdpvar(size(X,1),size(X,2));
                    if min(size(X))>1
                        F = set(-z < X < z) + set(sum(z,1) < t)
                    else
                        F = set(-z < X < z) + set(sum(z) < t);
                    end
                case 2
                    z = sdpvar(size(X,1),size(X,2));
                    if min(size(X))>1
                        F = set([t*eye(size(X,1)) X;X' t*eye(size(X,2))]);
                    else
                        F = set(cone(X(:),t));
                    end
                case inf
                    if min(size(X))>1
                        z = sdpvar(size(X,1),size(X,2));
                        F = set(-z < X < z) + set(sum(z,2) < t)
                    else
                        F = set(-t < X < t);
                    end
                case 'fro'
                    X.n=X.n*X.m;
                    X.m=1;
                    F = set(cone(X,t));
                otherwise
            end
            varargout{1} = F;
            varargout{2} = [1 0 1]; % Convex, neither nondecreasing nor nonincreasing, non-negative
            varargout{3} = {X};
        else
             error('SDPVAR/NORM called with CHAR argument?');
        end
    otherwise
        error('Strange type on first argument in SDPVAR/NORM');
end

⌨️ 快捷键说明

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