C++ Call Matlab error
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
While executing a C++ function called by Matlab I want to report errors back to Matlab. In the C mex API there is mexErrMsgTxt, but I haven't found any corresponding C++ calls. Tried using this helper function
void mxErrorMessage(std::string msg)
{
auto args = factory.createCharArray(msg);
matlabPtr->feval(u"error", args);
}
but I get the following error when I force it to be called
Error using error
Too many output arguments.
Is there a more Matlab appropriate solution that I am missing? Why am I getting this error?
2 commentaires
Rik
le 31 Déc 2020
I have no experience with C++, but the Matlab error sounds like C++ expects the error function to return an output, which it doesn't.
Réponses (1)
Rik
le 31 Déc 2020
The way I read the documentation page you linked, you need to do this:
// Call function with no output by using void as the type
matlabPtr->feval<void>(u"error", args);
Voir également
Catégories
En savoir plus sur Write C Functions Callable from MATLAB (MEX Files) dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!