interpolation.cpp
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 
27 
35 #include <acado_integrators.hpp>
36 #include <acado_gnuplot.hpp>
37 
39 
40 /* >>> start tutorial code >>> */
41 int main( )
42 {
43  // DEFINE A VARIABLES GRID:
44  // ------------------------
45  Grid dataGrid( 0.0, 5.0, 6 );
46 
47  VariablesGrid data;
48  data.init( 2, dataGrid );
49 
50  data( 0, 0 ) = 0.0; data( 0, 1 ) = 1.0 ;
51  data( 1, 0 ) = 0.2; data( 1, 1 ) = 0.8 ;
52  data( 2, 0 ) = 0.4; data( 2, 1 ) = 0.7 ;
53  data( 3, 0 ) = 0.6; data( 3, 1 ) = 0.65 ;
54  data( 4, 0 ) = 0.8; data( 4, 1 ) = 0.625;
55  data( 5, 0 ) = 1.0; data( 5, 1 ) = 0.613;
56 
57  // CONSTRUCT A CURVE INTERPOLATING THE DATA:
58  // -----------------------------------------
59 
60  Curve c1, c2;
61 
62  c1.add( data, IM_CONSTANT );
63  c2.add( data, IM_LINEAR );
64 
65 
66  // PLOT CURVES ON GIVEN GRID:
67  // --------------------------
68  GnuplotWindow window;
69  window.addSubplot( c1, 0.0,5.0, "Constant data Interpolation" );
70  window.addSubplot( c2, 0.0,5.0, "Linear data Interpolation" );
71  window.plot();
72 
73  return 0;
74 }
75 /* <<< end tutorial code <<< */
76 
77 
USING_NAMESPACE_ACADO int main()
virtual returnValue plot(PlotFrequency _frequency=PLOT_IN_ANY_CASE)
returnValue add(double tStart, double tEnd, const DVector constant)
Definition: curve.cpp:143
#define USING_NAMESPACE_ACADO
Provides a time grid consisting of vector-valued optimization variables at each grid point...
Allows to conveniently handle (one-dimensional) grids consisting of time points.
Definition: grid.hpp:58
returnValue addSubplot(PlotWindowSubplot &_subplot)
returnValue init()
Allows to work with piecewise-continous function defined over a scalar time interval.
Definition: curve.hpp:52
Provides an interface to Gnuplot for plotting algorithmic outputs.


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