I wrote a C++ program that uses Matlab Engine C++ API . The program builds fine, but when I run it, the call to startMATLAB() results in a "The specified module could not be found" message & an exception. Any suggestions? Thank you!

2 views (last 30 days)
#include "MatlabEngine.hpp"
#include iostream
#include string
#include vector
#include "MatlabDataArray.hpp"
void main(int argc, char** argv) {
//Start a MATLAB session and get a unique pointer to the instance.
std::cout << "testing MatlabAPI" << std::endl;
//Define a vector of MATLAB data arrays for the input arguments to the MATLAB function.Each argument is an array in the vector.
// Create a vector of MATLAB data arrays for arguments
std::vector<double> args({ 4, 8, 6, -1, -2, -3});
std::cout << args[0] << std::endl;
// start matlab engine
std::unique_ptr<matlab::engine::MATLABEngine> matlabPtr = matlab::engine::startMATLAB();
std::cout << "startMATLAB called" << std::endl;
//Create a MATLAB data array factory to construct the data types used by the matlab::engine::MATLABEngine member functions.
matlab::data::ArrayFactory factory;
std::cout << " create factory" << std::endl;
std::string line;
std::cout << "Press ENTER to try...";
std::getline(std::cin, line);
matlab::data::TypedArray<double> inputArray = factory.createArray({ 2, 3 }, args.cbegin(), args.cend());
//std::cout << inputArray[0][0] << std::endl;
}

Answers (0)

Community Treasure Hunt

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

Start Hunting!