to load Matlab executable once and keep calling the function many times?
2 次查看(过去 30 天)
显示 更早的评论
I have a requirement where in I need to load a matlab model and keep calling the function many times until user wants. I am trying to run the executable using Java. Once it is loaded i want to keep calling the function inside matlab model for 'n' number of times. is there any way to do it ? can someone suggest a good approach.
0 个评论
回答(1 个)
Walter Roberson
2020-9-28
If you know the number ahead of time, perhaps pass it as a command line argument? At least if your executable is MATLAB and not generated from Simulink: I do not know anything about the command line arguments for executables generated from Simulink.
Command line arguments for MATLAB functions called from the command line, are received as character vectors; you would need to str2double() or equivalent to use them as numeric values.
For example,
myexe 5
then function myexe would receive '5' (the character vector), and not numeric 5.
2 个评论
Walter Roberson
2020-9-28
If you are talking about repeated execution of the entire command to invoke MATLAB, then MATLAB has to re-create the process every time, doing nearly as much initialization as would be done for an interactive MATLAB session.
Mathworks sells a product that can reduce the startup time -- MATLAB Production Server. I have never seen a price quoted for it, so I suspect it is probably over $US10000.
You could consider re-implementing in terms of using the MATLAB Automation Server; see https://www.mathworks.com/help/matlab/call-matlab-com-automation-server.html . That technology permits you to start up a MATLAB instance and send it commands and get back responses, with the single process staying around until you tell it to quit. However, I am not at all certain that you can compile that server into an executable (to avoid needing a MATLAB license); I have the suspicion that you cannot do that kind of compilation and so might need the server engine to be a "real" MATLAB.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!