how to use a C++ program to call a Matlab script

56 views (last 30 days)
Lara on 8 Mar 2011
Commented: Matthew Holub on 25 Feb 2019
How to call a matlab script from an C++ program (not visual C) on Linux Red Hat. How easy is it to do this? What are the steps? How do I code C++ to invoke the script? How do I compile the C++ to create an executable? Can someone answer this? Is this supported on Red Hat Linux 5.5? Thanks.

Answers (1)

Kaustubha Govind
Kaustubha Govind on 8 Mar 2011
Edited: Kaustubha Govind on 30 Oct 2014
If you are running the C++ application on a machine that has MATLAB installed, see MATLAB Engine API for C, C++, and Fortran.
If you need to run this executable on a machine that does not have MATLAB installed, you can get the MATLAB Compiler to compile MATLAB code into a shared library and call it from your C++ code.
  1 Comment
Matthew Holub
Matthew Holub on 25 Feb 2019
I am trying to use the startMATLAB() function in c++, but I am getting a segmentation fault. Could you refer to my question here to try to help me out? :
Thank you very much

Sign in to comment.


Find more on C Shared Library Integration in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by