0

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.

Anthony
  • 3,595
  • 2
  • 29
  • 38
  • 1
    Read 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 Answers2

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
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);