call matlab (*.m) program from visual studio 2013

7 visualizaciones (últimos 30 días)
batsheva isakov
batsheva isakov el 4 de Mayo de 2014
Comentada: Image Analyst el 9 de Sept. de 2018
How can i call matlab (*.m) program from visual studio 2013?
Thanks for the answers!

Respuestas (3)

Dhanyatha
Dhanyatha el 30 de Jun. de 2014
You can utilize a (.m) file in MS Visual Studio in two ways:
1. Compiling the (.m) file using MATLAB Compiler , and then refer to the resulting DLL in your Visual Studio Program
2. Call the (.m) file using MATLAB Engine from your program.
Below is an example of calling "script.m" file in a C++ program using MATLAB Engine.
/* A simple program to illustrate how to call MATLAB Engine functions from a C++ program.*/
using namespace std;
#include "engine.h"
int main()
{
Engine *ep;
/*
* Call engOpen with a NULL string. This starts a MATLAB process
* on the current host using the command "matlab".
*/
if (!(ep = engOpen("")))
{
fprintf(stderr, "\nCan't start MATLAB engine\n");
return EXIT_FAILURE;
}
/*
* Now call the MATLAB script that through MATLAB Engine
*/
engEvalString(ep, "script");
cout << "Hit return to continue\n\n";
fgetc(stdin);
/*
* Close the MATLAB Engine
*/
engClose(ep);
return EXIT_SUCCESS;
}
  1 comentario
Ryan Livingston
Ryan Livingston el 30 de Jun. de 2014
3. If you adhere to the MATLAB subset supported for code generation, you could also generate C or C++ code from your MATLAB code using MATLAB Coder and then call that code from your Visual Studio project.

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 4 de Mayo de 2014
I think you'd need to compile it into a mex file with the MATLAB Compiler, and then call it as a DLL from your Visual Studio program. You might be able to use MATLAB Coder - I don't know because I don't have that product.

Ravi Boda
Ravi Boda el 9 de Sept. de 2018
I have written in visual studio 2013 then how to execute in matlab
  1 comentario
Image Analyst
Image Analyst el 9 de Sept. de 2018
To have MATLAB execute/launch a program you've created in Visual Studio, use the system() function. Pass in the full file name of the executable you made in Visual Studio into the system() function.

Iniciar sesión para comentar.

Categorías

Más información sobre Call MATLAB from C en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by