Questions tagged [matlab-engine]

MATLAB Engine is a library to call MATLAB® software from standalone programs, for example written in C/C++ or Fortran.

While files are DLLs encapsulating C/C++ or Fortran code to be used by a main program written in MATLAB, sometimes the inverse is necessary: A main program in C/C++ or Fortran needs to access MATLAB's capabilities. This can be done using MATLAB Engine, which is documented in the MATLAB online help.

Note that a second way to use MATLAB from C/C++ or Fortran is to turn the MATLAB code it be used into a library using MATLAB Compiler.

Questions should have this tag if they are about the use of MATLAB Engine specifically. If the issue also occurs with standalone MATLAB the tag should be avoided and be used instead.

183 questions
15
votes
2 answers

How to Call Matlab Functions from C++

I want to call MATLAB function in my C++ project. I'm using Matlab R2010a and Visual Studio 2010 First I created a simple matlab function: function y = foo(x) y = x+1; and then I used matlab compiler to compile this function using matlab GUI…
Amr Ramadan
  • 1,259
  • 5
  • 18
  • 29
13
votes
2 answers

How to efficiently convert Matlab engine arrays to numpy ndarray?

I am currently working on a project where I need do some steps of processing with legacy Matlab code (using the Matlab engine) and the rest in Python (numpy). I noticed that converting the results from Matlab's matlab.mlarray.double to numpy's…
Tim
  • 1,430
  • 15
  • 36
10
votes
4 answers

Problems including MATLAB "engine.h" for C++ code

I am trying to run the example code from the MATLAB Doc, but when I try to build the project in Visual Studio I get this error fatal error C1083: Cannot open include file: 'engine.h': No such file or directory The fact is that in the Doc I cannot…
Jav_Rock
  • 22,059
  • 20
  • 123
  • 164
10
votes
2 answers

matlab in C C++ and C C++ in matlab

It seems that are several ways to call matlab in C C++ and to call C C++ in matlab. While I try to list them here, please point it out If I miss something. To call C C++ in matlab, there are also two methods. The first one is to call functions in C…
Tim
  • 1
  • 141
  • 372
  • 590
9
votes
1 answer

Matlab engines within parallel loop

I am having some trouble utilising multiple matlab engines from within a piece of parallelised code. I can successfully spawn multiple engines using engOpenSingleUse but am unable to communicate with more than one engine (ie. calls to engPutVariable…
Ingo
  • 141
  • 3
8
votes
2 answers

C++ source compilation using MATLAB Engine and g++

It would be helpful if you could provide some guidance on how to compile c++ source code files in an Ubuntu environment, using the MATLAB Engine with g++.
obelix
  • 880
  • 2
  • 16
  • 43
8
votes
4 answers

Thread safety of Matlab engine API

I have discovered through trial and error that the MATLAB engine function is not completely thread safe. Does anyone know the rules? Discovered through trial and error: On Windows, the connection to MATLAB is via COM, so the COM Apartment threading…
Jeremy
  • 2,321
  • 3
  • 21
  • 24
8
votes
2 answers

Connect to Matlab engine from C in Linux

I'm trying to call the Matlab engine programatically from a C program on Linux (Matlab r2009a, Ubuntu 9.10). I've got my own code (which works in Windows), but for now I'm just trying to get the Matlab "engdemo.c" program to work on Linux. I have…
Drew Hall
  • 28,429
  • 12
  • 61
  • 81
7
votes
3 answers

Set processor affinity for MATLAB engine (Windows 7)

I'm developing an application in c++. One of the components of the application uses Matlab (via the Matlab engine) for data processing. At the same time, a data acquisition system is streaming data to disk. Occasionally, during periods of intensive…
tmpearce
  • 12,523
  • 4
  • 42
  • 60
7
votes
3 answers

Convert data from cv::Mat to mxArray

I want to send a Matrix to Matlab using "engine.h" in c++ code. The fact is that I have the data inside a cv::Mat, and I need to sent a mxArray. I tried to use this expression but it doesn´t work: cv::Mat _priorP; _priorP = Mat::eye(13, 13,…
Jav_Rock
  • 22,059
  • 20
  • 123
  • 164
7
votes
1 answer

Sending data from OpenCV matrix to Matlab Engine, C++

I am sending data from OpenCV matrices to matlab using C++ and Matlab Engine. I tried to convert from column major to row major but I am really confused on how to do that. I cannot understand how to deal with Matlab pointer mxArray and put data to…
vgonisanz
  • 11,831
  • 13
  • 78
  • 130
6
votes
4 answers

Calling matlab from C++

I tried to call matlab from a .cpp file. I used the following command to compile engdemo.cpp which includes "engine.h" g++ engdemo.cpp -I/usr/local/matlabR2010a/extern/include -L/usr/local/matlabR2010a/extern/lib -o engdemo What I got is the…
Lamothy
  • 337
  • 4
  • 17
6
votes
2 answers

Delay loading dll in release mode

In a C project i'm building in Visual Studio (C++ 2010 Express), I use the MatLab engine to allow for a user to provide a custom function to use within the project. The problem is that this code also needs to be able to run on computers without…
6
votes
3 answers

Connect to already running MATLAB with MATLAB Engine

The MATLAB Engine API allows accessing MATLAB functionality from a C program. To set up a MATLAB Engine session, one calls the engOpen function. By default, this launches a new instance of MATLAB, for the exclusive use of Engine applications. What…
Szabolcs
  • 24,728
  • 9
  • 85
  • 174
6
votes
1 answer

C pointers to Matlab variables

I'm working on a C program that needs to repeatedly access a large Matlab data structure. This is a graphics intensive program using OpenGL so it has to be fast. Repeatedly accessing this data structure with Matlab Engine seems to take too long (~…
Eric Miller
  • 110
  • 7
1
2 3
12 13