I have written a machine learning algorithm (MLP) for prediction in matlab, I want to call it, in a specific times, in a simulation (OMNET++) that is based on c++. how can I call this ML algorithm in this c++ program? my implementations is in linux. many thanks.
Asked
Active
Viewed 89 times
0
-
1Read this: [MATLAB C++ Libraries](https://uk.mathworks.com/help/matlab/call-cpp-library-functions.html) and [Call MATLAB Functions from C++](https://uk.mathworks.com/help/matlab/matlab_external/call-matlab-functions-from-c-1.html) – Anthony May 07 '19 at 09:00
2 Answers
1
You can use this to execute any file from within a C++ code.
system(<matlab_file_name>)
Usage example: Launch an instance of notepad from a c++ file:
int main()
{
cout << "Launching notepad..." <<endl;
system("notepad.exe");
return 0;
}

Saket Sharad
- 392
- 2
- 11
-
-
-
1MATLAB script is not an executable file unless published, which requires additional licenced toolbox. – Anthony May 07 '19 at 09:03
0
I run this code and it works.
const char* cmd1="gnome-terminal -x sh -c \'/usr/local/MATLAB/R2016a/bin/matlab -nodisplay -nosplash -nodesktop -r \"run(\'/home/veins/MLP/estimate.m\');exit;\'";
int s=system(cmd1);

user4173004
- 19
- 4
-
this also works. https://stackoverflow.com/questions/32115766/how-to-execute-a-matlab-script-from-c – user4173004 May 19 '19 at 07:44