compile MatLab into standalone exe, how to pass matrices as input.

7 visualizaciones (últimos 30 días)
Lu Liu
Lu Liu el 9 de En. de 2019
Editada: dpb el 10 de En. de 2019
Hi,
I compiled my MatLab model into a standalone exe, I am looking for ways to pass matrices as input. According to the compiler documentation -> passing arguments to and from a standalone application, it mentioned that argument from command line is considered as string input, therefore we need to adjust MatLab model to be aware of that. It also showed example to convert string to double. But how about matrices/vectors? If my function accepts input as matrices, how do I pass it from command line? Thanks!

Respuesta aceptada

dpb
dpb el 9 de En. de 2019
"[A]rguments can be passed to standalone applications created using MATLAB® Compiler™ in the same way that input arguments are passed to any console-based application"
This means the application doesn't get an array but the string representation of the array and there's no connection to command line arguments to ML variables excepting by writing code to parse those arguments and place the result in the proper variable.
Sad, but true; when an app is compiled, it becomes just like any other console application; all the interaction with Matlab and the command window and variables known in Matlab when the compiled app is dispatched are simply not there between the two any longer...all the app has access to is the text on the command line to retrieve and do with what it will.
For anything but the most trivial of inputs, it's probably better to use a file for the purpose.
  3 comentarios
dpb
dpb el 9 de En. de 2019
Editada: dpb el 10 de En. de 2019
I dunno much about the DLL interface route, sorry.
If you were to write a .mex function, it could be called like any other Matlab function and be passed any of the base ML datatypes -- I've not checked recently whether the API has been extended to a bunch of the more recent and exotic new datatypes/classes or not, but certainly arrays of double and the like...
Lu Liu
Lu Liu el 9 de En. de 2019
Thanks again, I tried to convert my C++ input parameter to mwarray and then call the ML model and it seems to work. However, I end up having to compile my C++ into a DLL, while referencing the ML model in a DLL, too, this leads to some issues. Will look into this more tomorrow.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Deploy to C++ Applications Using mwArray API (C++03) 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!

Translated by