Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

matlab_engine.h

Go to the documentation of this file.
00001 // From IT++ although no copyright info in original file
00002 // SPUC - Signal processing using C++ - A DSP library
00003 /* 
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2, or (at your option)
00007  * any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 #ifndef _MATLAB_ENGINE
00019 #define _MATLAB_ENGINE
00020 
00021 #include "scalfunc.h"
00022 #include "matrix.h"
00023 #include "matfunc.h"
00024 #include "specmat.h"
00025 
00026 #include "converters.h"
00027 #include "fastmath.h"
00028 
00029 #include <mat.h>
00030 #include <engine.h>
00031 namespace SPUC {
00033 /* Example code: */
00034 
00035 /* vec x, y; */
00036 /* x=linspace(0, 2*3.14, 200); */
00037 /* y=sin(4*x); */
00038 
00039 /* Matlab_Engine e; */
00040 /* e.put(x, "x"); */
00041 /* e.put(y, "y"); */
00042 /* e.command("plot(x, y);"); */
00043 /* e.command("xlabel('x');"); */
00044 /* e.command("ylabel('sin(4x)');"); */
00045 
00046 /* It++ does not differ between row or column vectors. When a length N vector is 'put' to  */
00047 /* the Matlab workspace it is stored as a N x 1 column vector. If you are concerned about the  */
00048 /* dimension of the variables you 'get' from the Matlab workspace to your it++ program, you should use  */
00049 /* the matrix versions of the 'get' command. The complex versions of the 'get' command work */
00050 /* also on a real valued variable. */
00051 class Matlab_Engine{
00052  public:
00053   
00054   /* Give the command to start Matlab on your system or try the default one. */
00055   Matlab_Engine(const char *start_command = "matlab -nojvm");
00056   ~Matlab_Engine();
00057 
00058   /* Transfer the it++ vector 'v' to the Matlab workspace and give it the name 'name'. */
00059   void put(const vec &v, const char *name);
00060   void put(const ivec &v, const char *name);
00061   void put(const bvec &v, const char *name);
00062   void put(const cvec &v, const char *name);
00063 
00064   /* Transfer the it++ matrix 'm' to the Matlab workspace and give it the name 'name'. */
00065   void put(const mat &m, const char *name);
00066   void put(const imat &m, const char *name);
00067   void put(const bmat &m, const char *name);
00068   void put(const cmat &m, const char *name);
00069 
00070   /* Transfer the Matlab vector with name 'name' to the it++ program. */
00071   void get(vec &v, const char *name);
00072   void get(cvec &m, const char *name);
00073 
00074   /* Transfer Matlab matrix with name 'name' to the it++ program. */
00075   void get(mat &m, const char *name);
00076   void get(cmat &m, const char *name);
00077 
00078   /* Same as above but returns via the stack instead. */
00079   vec get_vec(const char *name);
00080   mat get_mat(const char *name);
00081   cvec get_cvec(const char *name);
00082   cmat get_cmat(const char *name);
00083 
00084   /* Execute the Matlab command given in 'c'. */
00085   void command(const char *c);
00086 
00087  private:
00088   Engine *e;
00089 };
00090 }
00091 #endif // _MATLAB_ENGINE

Generated on Fri Sep 16 11:02:30 2005 for spuc by  doxygen 1.4.4