How can I invoke C++ executable file (.exe) from Matlab code or Simulink?
19 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Rutwesh Shirbhate
el 20 de Ag. de 2020
Editada: Rutwesh Shirbhate
el 27 de Ag. de 2020
I am trying to run a C++ executable file (.exe) from matlab or Simulink. Currently I have to run the ++ executable file (.exe) manually and start the simulation in matlab environment to start the data exchange between matlab and C++ code. Is there any easier way to automate the process? Eg- I can just run matlab/Simulink and the C++ executable file (.exe) is invoked.
Operating system - Windows10
Matlab - 2017a/b
User Datagram Protocol (UDP) is used between matlab and C++
5 comentarios
Respuesta aceptada
Mohammad Sami
el 20 de Ag. de 2020
As Walter suggested you can use .Net System.Diagnostic.Process to run it.
This way you will also be able to terminate the program.
process = System.Diagnostics.Process();
process.StartInfo.FileName = 'java.exe';
process.StartInfo.Arguments = 'some args';
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = false;
process.StartInfo.CreateNoWindow = false;
process.Start();
processisrunning = ~process.HasExited;
You can then close it as follows
process.Close();
% or
process.CloseMainWindow();
% or terminate immediately
process.Kill();
4 comentarios
Mohammad Sami
el 22 de Ag. de 2020
If your exe takes arguments you can specify them with Arguments. If you wish to hide the window of your exe you can see create no window to true. You can find more information in documentation on Microsoft website.
Más respuestas (0)
Ver también
Categorías
Más información sobre External Language Interfaces en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!