Home > matlab > acado > packages > +acado > @Addition > Addition.m

Addition

PURPOSE ^

Addition of expressions.

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

Addition of expressions.

  Usage:
    >> Addition(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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 %Addition of expressions.
0002 %
0003 %  Usage:
0004 %    >> Addition(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 Addition < acado.BinaryOperator
0036     properties(SetAccess='private')
0037 
0038     end
0039     
0040     methods
0041         function obj = Addition(varargin)
0042             if (nargin == 1)
0043                 obj.obj2 = varargin{1};
0044                 obj.obj1 = acado.EmptyWrapper();      
0045                 
0046             elseif (nargin == 2)
0047                 if (isa(varargin{1}, 'numeric'))
0048                     varargin{1} = acado.DoubleConstant(varargin{1});
0049                 elseif (isa(varargin{2}, 'numeric'))
0050                     varargin{2} = acado.DoubleConstant(varargin{2});
0051                 end
0052 
0053                 obj.obj1 = varargin{1};
0054                 obj.obj2 = varargin{2};
0055             else
0056                 error('Invalid addition');
0057             end
0058         end
0059         
0060         function s = toString(obj)
0061             s = sprintf(' %s + %s ', obj.obj1.toString, obj.obj2.toString); 
0062         end
0063     end
0064     
0065 end
0066

www.acadotoolkit.org/matlab
Generated on Tue 01-Jun-2010 20:14:12 by m2html © 2005