


A matrix built from standard Matlab matrix notations.
Stored both as a Matrix and as a VariablesGrid Object
Usage:
>> Matrix([MATRIX]);
Parameters:
[MATRIX] a numeric m x n matrix
Example:
>> m = acado.Matrix([1,2,3;4,5,6;7,8,9]);
>> Q = eye(3,3); m = acado.Matrix(Q);
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: 2010


0001 %A matrix built from standard Matlab matrix notations. 0002 % Stored both as a Matrix and as a VariablesGrid Object 0003 % 0004 % Usage: 0005 % >> Matrix([MATRIX]); 0006 % 0007 % Parameters: 0008 % [MATRIX] a numeric m x n matrix 0009 % 0010 % 0011 % Example: 0012 % >> m = acado.Matrix([1,2,3;4,5,6;7,8,9]); 0013 % >> Q = eye(3,3); m = acado.Matrix(Q); 0014 % 0015 % 0016 % Licence: 0017 % This file is part of ACADO Toolkit - (http://www.acadotoolkit.org/) 0018 % 0019 % ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization. 0020 % Copyright (C) 2008-2009 by Boris Houska and Hans Joachim Ferreau, K.U.Leuven. 0021 % Developed within the Optimization in Engineering Center (OPTEC) under 0022 % supervision of Moritz Diehl. All rights reserved. 0023 % 0024 % ACADO Toolkit is free software; you can redistribute it and/or 0025 % modify it under the terms of the GNU Lesser General Public 0026 % License as published by the Free Software Foundation; either 0027 % version 3 of the License, or (at your option) any later version. 0028 % 0029 % ACADO Toolkit is distributed in the hope that it will be useful, 0030 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0031 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0032 % Lesser General Public License for more details. 0033 % 0034 % You should have received a copy of the GNU Lesser General Public 0035 % License along with ACADO Toolkit; if not, write to the Free Software 0036 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 0037 % 0038 % Author: David Ariens 0039 % Date: 2010 0040 % 0041 classdef Matrix < acado.VectorspaceElement 0042 properties 0043 name_m = ''; %nameMatrix 0044 matrixIsPrinted=0; 0045 end 0046 0047 methods 0048 function obj = Matrix(val) 0049 0050 global ACADO_; 0051 0052 if (isa(val, 'numeric')) 0053 ACADO_.count_matrix = ACADO_.count_matrix+1; 0054 obj.name = strcat('acadodata_M', num2str(ACADO_.count_matrix)); 0055 0056 obj.name_m = strcat(obj.name, '_m'); 0057 0058 obj.items = val; 0059 0060 ACADO_.helper.addInstruction(obj); 0061 0062 elseif (isa(val, 'acado.MexInput')) 0063 0064 if (val.type ~= 3) 0065 error('MexInput should be in this case a matrix, not a scalar or vector.'); 0066 end 0067 0068 obj.name = val.name; 0069 obj.name_m = val.name_m; 0070 0071 else 0072 error('Matrix expects a numeric value or a acado.MexInput'); 0073 0074 end 0075 0076 end 0077 0078 getInstructions(obj, cppobj, get) 0079 0080 % 0081 % function printMatrix(obj, cppobj) 0082 % % Normal matrices are stored as VariablesGrids. If a matrix 0083 % % should be used as a "Matrix" object, call this method 0084 % 0085 % if (obj.matrixIsPrinted ~= 1) 0086 % fprintf(cppobj.fileMEX,sprintf(' Matrix %s(%s);\n', obj.nameMatrix, obj.name)); 0087 % 0088 % obj.matrixIsPrinted = 1; 0089 % end 0090 % 0091 % end 0092 0093 0094 end 0095 0096 end 0097