matlab_acado_utils.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of ACADO Toolkit.
3  *
4  * ACADO Toolkit -- A Toolkit for Automatic Control and Dynamic Optimization.
5  * Copyright (C) 2008-2014 by Boris Houska, Hans Joachim Ferreau,
6  * Milan Vukov, Rien Quirynen, KU Leuven.
7  * Developed within the Optimization in Engineering Center (OPTEC)
8  * under supervision of Moritz Diehl. All rights reserved.
9  *
10  * ACADO Toolkit is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 3 of the License, or (at your option) any later version.
14  *
15  * ACADO Toolkit is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with ACADO Toolkit; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  *
24  */
25 
26 
39 #ifndef ACADO_TOOLKIT_MATLAB_UTILS_HPP
40 #define ACADO_TOOLKIT_MATLAB_UTILS_HPP
41 
42 
43 #include <math.h>
44 #include <mex.h>
45 
47 
48 
50 
51 
52 int isScalar( const mxArray* const M )
53 {
54  if ( ( mxGetM( M ) != 1 ) || ( mxGetN( M ) != 1 ) )
55  return 0;
56  else
57  return 1;
58 }
59 
60 
61 int isFunctionHandle( const mxArray* const M )
62 {
63  if ( M == NULL )
64  return 0;
65 
66  if ( mxIsCell(M) )
67  return 0;
68 
69  if ( mxIsChar(M) )
70  return 0;
71 
72  if ( mxIsComplex(M) )
73  return 0;
74 
75  if ( mxIsDouble(M) )
76  return 0;
77 
78  if ( mxIsEmpty(M) )
79  return 0;
80 
81  if ( mxIsInt8(M) )
82  return 0;
83 
84  if ( mxIsInt16(M) )
85  return 0;
86 
87  if ( mxIsInt32(M) )
88  return 0;
89 
90  if ( mxIsLogical(M) )
91  return 0;
92 
93  if ( mxIsLogicalScalar(M) )
94  return 0;
95 
96  if ( mxIsLogicalScalarTrue(M) )
97  return 0;
98 
99  if ( mxIsNumeric(M) )
100  return 0;
101 
102  if ( mxIsSingle(M) )
103  return 0;
104 
105  if ( mxIsSparse(M) )
106  return 0;
107 
108  if ( mxIsStruct(M) )
109  return 0;
110 
111  if ( mxIsUint8(M) )
112  return 0;
113 
114  if ( mxIsUint16(M) )
115  return 0;
116 
117  if ( mxIsUint32(M) )
118  return 0;
119 
120  // assume to be a function handle iff it is nothing else
121  return 1;
122 }
123 
124 
126 
127  mxArray *XTrajectory = NULL;
128  double *xTrajectory = NULL;
129 
130  XTrajectory = mxCreateDoubleMatrix( grid.getNumPoints(),1+grid.getNumValues(),mxREAL );
131  xTrajectory = mxGetPr( XTrajectory );
132 
133  for( int i=0; i<grid.getNumPoints(); ++i ){
134  xTrajectory[0*grid.getNumPoints() + i] = grid.getTime(i);
135  for( int j=0; j<grid.getNumValues(); ++j ){
136  xTrajectory[(1+j)*grid.getNumPoints() + i] = grid(i, j);
137  }
138  }
139 
140 
141  mxArray* plotArguments[] = { XTrajectory };
142  mexCallMATLAB( 0,0,1,plotArguments,"acadoPlot" );
143 
144 }
145 
146 
147 
149 
150 
151 
152 #endif // ACADO_TOOLKIT_MATLAB_UTILS_HPP
153 
154 
155 /*
156  * end of file
157  */
int isFunctionHandle(const mxArray *const M)
void acadoPlot(VariablesGrid grid)
double getTime(uint pointIdx) const
Provides a time grid consisting of vector-valued optimization variables at each grid point...
BEGIN_NAMESPACE_ACADO int isScalar(const mxArray *const M)
#define CLOSE_NAMESPACE_ACADO
uint getNumPoints() const
#define BEGIN_NAMESPACE_ACADO


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:50