📄 abs.m
字号:
function varargout=abs(varargin)
%ABS (overloaded)
%
% t = abs(x)
%
% The variable t can only be used in convexity preserving
% operations such as t<0, min t etc.
% Author Johan L鰂berg
% $Id: abs.m,v 1.8 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/ABS CALLED WITH DOUBLE. Report error')
case 'sdpvar' % Overloaded operator for SDPVAR objects. Pass on args and save them.
if isreal(varargin{1})
varargout{1} = yalmip('addextendedvariable',mfilename,varargin{1});
else
% For complex args, abs(X) is defined [abs(X(i,j)] in MATLAB
y = [];
x = varargin{1};
for i = 1:size(x,1)
temp = [];
for j = 1:size(x,2)
temp = [temp norm(ihatethis(x,i,j))];
end
y = [y;temp];
end
varargout{1} = y;
end
case 'char' % YALMIP send 'graph' when it wants the epigraph or hypograph
if isequal(varargin{1},'graph')
t = varargin{2};
X = varargin{3};
varargout{1} = set(-t < X < t);
varargout{2} = 1; % Convex operator
else
error('SDPVAR/ABS called with CHAR argument?');
end
otherwise
error('Strange type on first argument in SDPVAR/ABS');
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -