chrono::ChMatlabEngine Class Reference

Description

Class for accessing the Matlab engine with a C++ wrapper.

When a ChMatlabEngine object is instanced, a Matlab engine is started (assuming Matlab is properly installed and its dll are available on the system) and following funcitons can be used to copy variables from/to Chrono, and to execute commands in Matlab. Useful also to exploit the powerful plotting features of Matlab. Note! to compile programs that include this header, your makefile must be properly configured to set the Matlab SDK directory, so that matlab headers and libs can be compiled/linked Also, if you run an executable that used this header on a system that has no Matlab installed, a 'missing dll' error will pop up as soon as you try to start the program.

#include <ChMatlabEngine.h>

Public Member Functions

matlabengine::Engine * GetEngine ()
 Return pointer to internal Matlab engine (avoid using it directly, if you can use other functions of this class that 'wrap' it.)
 
bool Eval (std::string mstring)
 Evaluate a Matlab instruction (as a string). If error happens while executing, returns false.
 
bool SetVisible (bool mvis)
 Set visibility of GUI matlab window.
 
bool PutVariable (ChMatrixConstRef mmatr, std::string varname)
 Put a matrix in Matlab environment, specifying its name as variable. More...
 
bool PutSparseMatrix (const ChSparseMatrix &mmatr, std::string varname)
 Put a sparse matrix in Matlab environment, specifying its name as variable. More...
 
bool GetVariable (ChMatrixDynamic< double > &mmatr, std::string varname)
 Fetch a matrix from Matlab environment, specifying its name as variable. More...
 
bool GetString (std::string &str, std::string varname)
 Fetch a string from Matlab environment, specifying its name as variable.
 
void KeepEngineOpen (bool open)
 Keep matlab engine open even after termination of C++ program. More...
 
virtual void ArchiveOut (ChArchiveOut &archive_out)
 
virtual void ArchiveIn (ChArchiveIn &archive_in)
 Method to allow de serialization of transient data from archives.
 

Member Function Documentation

◆ GetVariable()

bool chrono::ChMatlabEngine::GetVariable ( ChMatrixDynamic< double > &  mmatr,
std::string  varname 
)

Fetch a matrix from Matlab environment, specifying its name as variable.

The used matrix must be of ChMatrixDynamic<double> type because it might undergo resizing.

◆ KeepEngineOpen()

void chrono::ChMatlabEngine::KeepEngineOpen ( bool  open)

Keep matlab engine open even after termination of C++ program.

Useful to skip initial time to reload engine (NB: thus, it must be closed manually).

◆ PutSparseMatrix()

bool chrono::ChMatlabEngine::PutSparseMatrix ( const ChSparseMatrix mmatr,
std::string  varname 
)

Put a sparse matrix in Matlab environment, specifying its name as variable.

If a variable with the same name already exist, it is overwritten.

◆ PutVariable()

bool chrono::ChMatlabEngine::PutVariable ( ChMatrixConstRef  mmatr,
std::string  varname 
)

Put a matrix in Matlab environment, specifying its name as variable.

If a variable with the same name already exist, it is overwritten.


The documentation for this class was generated from the following files:
  • /builds/uwsbel/chrono/src/chrono_matlab/ChMatlabEngine.h
  • /builds/uwsbel/chrono/src/chrono_matlab/ChMatlabEngine.cpp