matlab_acado_utils.hpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of ACADO Toolkit.
00003  *
00004  *    ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
00005  *    Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
00006  *    Milan Vukov, Rien Quirynen, KU Leuven.
00007  *    Developed within the Optimization in Engineering Center (OPTEC)
00008  *    under supervision of Moritz Diehl. All rights reserved.
00009  *
00010  *    ACADO Toolkit is free software; you can redistribute it and/or
00011  *    modify it under the terms of the GNU Lesser General Public
00012  *    License as published by the Free Software Foundation; either
00013  *    version 3 of the License, or (at your option) any later version.
00014  *
00015  *    ACADO Toolkit is distributed in the hope that it will be useful,
00016  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  *    Lesser General Public License for more details.
00019  *
00020  *    You should have received a copy of the GNU Lesser General Public
00021  *    License along with ACADO Toolkit; if not, write to the Free Software
00022  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023  *
00024  */
00025 
00026 
00039 #ifndef ACADO_TOOLKIT_MATLAB_UTILS_HPP
00040 #define ACADO_TOOLKIT_MATLAB_UTILS_HPP
00041 
00042 
00043 #include <math.h>
00044 #include <mex.h>
00045 
00046 #include <acado/utils/acado_namespace_macros.hpp>
00047 
00048 
00049 BEGIN_NAMESPACE_ACADO
00050 
00051 
00052 int isScalar( const mxArray* const M )
00053 {
00054         if ( ( mxGetM( M ) != 1 ) || ( mxGetN( M ) != 1 ) )
00055                 return 0;
00056         else
00057                 return 1;
00058 }
00059 
00060 
00061 int isFunctionHandle( const mxArray* const M )
00062 {
00063         if ( M == NULL )
00064                 return 0;
00065 
00066         if ( mxIsCell(M) )
00067                 return 0;
00068 
00069         if ( mxIsChar(M) )
00070                 return 0;
00071 
00072         if ( mxIsComplex(M) )
00073                 return 0;
00074 
00075         if ( mxIsDouble(M) )
00076                 return 0;
00077 
00078         if ( mxIsEmpty(M) )
00079                 return 0;
00080 
00081         if ( mxIsInt8(M) )
00082                 return 0;
00083 
00084         if ( mxIsInt16(M) )
00085                 return 0;
00086 
00087         if ( mxIsInt32(M) )
00088                 return 0;
00089 
00090         if ( mxIsLogical(M) )
00091                 return 0;
00092 
00093         if ( mxIsLogicalScalar(M) )
00094                 return 0;
00095 
00096         if ( mxIsLogicalScalarTrue(M) )
00097                 return 0;
00098 
00099         if ( mxIsNumeric(M) )
00100                 return 0;
00101 
00102         if ( mxIsSingle(M) )
00103                 return 0;
00104 
00105         if ( mxIsSparse(M) )
00106                 return 0;
00107 
00108         if ( mxIsStruct(M) )
00109                 return 0;
00110 
00111         if ( mxIsUint8(M) )
00112                 return 0;
00113 
00114         if ( mxIsUint16(M) )
00115                 return 0;
00116 
00117         if ( mxIsUint32(M) )
00118                 return 0;
00119 
00120         // assume to be a function handle iff it is nothing else
00121         return 1;
00122 }
00123 
00124 
00125 void acadoPlot(VariablesGrid grid){
00126 
00127         mxArray *XTrajectory = NULL;
00128         double  *xTrajectory = NULL;
00129 
00130     XTrajectory = mxCreateDoubleMatrix( grid.getNumPoints(),1+grid.getNumValues(),mxREAL );
00131     xTrajectory = mxGetPr( XTrajectory );
00132 
00133     for( int i=0; i<grid.getNumPoints(); ++i ){
00134         xTrajectory[0*grid.getNumPoints() + i] = grid.getTime(i);
00135         for( int j=0; j<grid.getNumValues(); ++j ){
00136             xTrajectory[(1+j)*grid.getNumPoints() + i] = grid(i, j);
00137         }
00138     }
00139 
00140 
00141     mxArray* plotArguments[] = { XTrajectory };
00142     mexCallMATLAB( 0,0,1,plotArguments,"acadoPlot" );
00143 
00144 }
00145 
00146 
00147 
00148 CLOSE_NAMESPACE_ACADO
00149 
00150 
00151 
00152 #endif   // ACADO_TOOLKIT_MATLAB_UTILS_HPP
00153 
00154 
00155 /*
00156  *    end of file
00157  */


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:59:10