Sample combination of Veins and MATLAB
Supported program versions
- Veins 5a1 (see http://veins.car2x.org/)
- OMNeT++ 5.4.1 (see https://omnetpp.org/)
- MATLAB R2019a (see https://www.mathworks.com/products/matlab/)
- Windows 10
- Ubuntu 18.04
- macOS 10.14
First, make sure that you are using compatible program versions (see above) on a compatible platform (see above).
Make sure that MATLAB is set up and working.
Within MATLAB, change to the
matlab/ subdirectory of
If you are using Windows, make sure to open MATLAB from the Start Menu or Explorer (do not open MATLAB from an OMNeT++ shell, as this changes environment variables that session sharing will rely on to work).
In MATLAB, open the
init.m file and run it.
This will set up a shared session called
Also, make sure that Veins is set up and working from the command line by opening an OMNeT++ shell, navigating to the Veins directory, and executing
./configure followed by
Change to the
examples/veins subdirectory and run
./run to confirm Veins is working.
Use the same command line window for entering any of the following commands.
In the command line window, change to the
Determine where your installation of MATLAB is located.
The directory you are looking for will contain a file
VersionInfo.xml and should be one level up from where the
matlab.exe) binary is located.
Pass this path as an argument to
./configure --with-matlab=..., similar to one of the following lines:
./configure --with-matlab=/opt/matlab/R2019a ./configure --with-matlab=/Applications/MATLAB_R2019a.app ./configure --with-matlab=/c/ProgramFiles/MATLAB/R2019a
veins_matlab by running
veins_matlab by running
cd examples/veins_matlab ./run -u Cmdenv
You should see the following output (amidst other OMNeT++ output):
[INFO] General:0 MATLAB result is 11 [INFO] General:0 MATLAB result is 12 [INFO] General:0 MATLAB result is 13
Building with MATLAB installed in a location containing spaces is not supported. Creating a symlink (on Windows: a directory junction, that is, running something like
mklink /J ProgramFiles "Program Files") can work around this bug.
Running in debug mode appends
_dbgto the library names of MATLAB as well. This means, OMNeT++ will try to load libraries
libMatlabEngine_dbg. Creating a symlink from (or simply copying), e.g.,
libMatlabEngine_dbg.dllcan work around this bug.