Subtraction of expressions. Usage: >> Subtraction(obj1, obj2); Parameters: obj1 [Expression] obj2 [Expression] Licence: This file is part of ACADO Toolkit - (http://www.acadotoolkit.org/) ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization. Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven. Developed within the Optimization in Engineering Center (OPTEC) under supervision of Moritz Diehl. All rights reserved. ACADO Toolkit is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. ACADO Toolkit is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with ACADO Toolkit; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Author: David Ariens Date: 2009
0001 %Subtraction of expressions. 0002 % 0003 % Usage: 0004 % >> Subtraction(obj1, obj2); 0005 % 0006 % Parameters: 0007 % obj1 [Expression] 0008 % obj2 [Expression] 0009 % 0010 % Licence: 0011 % This file is part of ACADO Toolkit - (http://www.acadotoolkit.org/) 0012 % 0013 % ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization. 0014 % Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven. 0015 % Developed within the Optimization in Engineering Center (OPTEC) under 0016 % supervision of Moritz Diehl. All rights reserved. 0017 % 0018 % ACADO Toolkit is free software; you can redistribute it and/or 0019 % modify it under the terms of the GNU Lesser General Public 0020 % License as published by the Free Software Foundation; either 0021 % version 3 of the License, or (at your option) any later version. 0022 % 0023 % ACADO Toolkit is distributed in the hope that it will be useful, 0024 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0025 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0026 % Lesser General Public License for more details. 0027 % 0028 % You should have received a copy of the GNU Lesser General Public 0029 % License along with ACADO Toolkit; if not, write to the Free Software 0030 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0031 % 0032 % Author: David Ariens 0033 % Date: 2009 0034 % 0035 classdef Subtraction < acado.BinaryOperator 0036 properties(SetAccess='private') 0037 0038 end 0039 0040 methods 0041 function obj = Subtraction(varargin) 0042 0043 if (nargin == 1) 0044 obj.obj2 = varargin{1}; 0045 obj.obj1 = acado.EmptyWrapper(); 0046 0047 elseif (nargin == 2) 0048 if (isa(varargin{1}, 'numeric')) 0049 varargin{1} = acado.DoubleConstant(varargin{1}); 0050 elseif (isa(varargin{2}, 'numeric')) 0051 varargin{2} = acado.DoubleConstant(varargin{2}); 0052 end 0053 0054 obj.obj1 = varargin{1}; 0055 obj.obj2 = varargin{2}; 0056 else 0057 error('Invalid subtraction'); 0058 end 0059 end 0060 0061 function s = toString(obj) 0062 s = sprintf(' %s - %s ', obj.obj1.toString, obj.obj2.toString); 0063 end 0064 end 0065 0066 end 0067