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

조회 수: 7 (최근 30일)
Lu Liu
Lu Liu 2019년 1월 9일
편집: dpb 2019년 1월 10일
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!

채택된 답변

dpb
dpb 2019년 1월 9일
"[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
dpb
dpb 2019년 1월 9일
편집: dpb 2019년 1월 10일
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 2019년 1월 9일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Deploy to C++ Applications Using mwArray API (C++03)에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by