sqrt.m

来自「matlab波形优化算法经常要用到的matlab toolbox工具箱:yalm」· M 代码 · 共 42 行

M
42
字号
function varargout = SQRT(varargin)
%SQRT (overloaded)
%
% t = sqrt(x)
%
% The variable t can only be used in concavity preserving
% operations such as t>1, max t etc.
%
% When SQRT is used in a problem, the domain constraint
% set(x>0) is automatically added to the problem.
%
% See also SDPVAR, SDPVAR/GEOMEAN

% Author Johan L鰂berg
% $Id: sqrt.m,v 1.1 2006/08/10 18:00:22 joloef Exp $

switch class(varargin{1})
    
case 'double' % What is the numerical value of this argument (needed for displays etc)        
    X = sqrt(varargin{1});

case 'sdpvar' % Overloaded operator for SDPVAR objects. Pass on args and save them.
    X = varargin{1};
    [n,m] = size(X);
    if is(varargin{1},'real') & (n*m==1)
        varargout{1} = yalmip('addextendedvariable',mfilename,varargin{:});    
    else
        error('SQRT can only be applied to real scalars');
    end
    
case 'char' % YALMIP send 'model' when it wants the epigraph or hypograph
    if isequal(varargin{1},'graph')
        t = varargin{2}; % Second arg is the extended operator variable
        X = varargin{3}; % Third arg and above are the args user used when defining t.           
        varargout{1} = set(cone([(X-1)/2;t],(X+1)/2));
        varargout{2} = struct('convexity','concave','monotonicity','increasing','definiteness','positive');
        varargout{3} = X;
    else           
    end    
otherwise
end

⌨️ 快捷键说明

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