Use sub-function inside of an .exe file (generated by matlab)

3 次查看(过去 30 天)
I want to convert a script main.m,which uses a sub-function,into a standalone main.exe file. I tried using nested function inside the script but it doesn't work.The sub-function is being used multiple times during execution and it is quite large.Is there any way I can make this work? Maybe convert both script and sub-function into two exe files and make one call the other?
% script main.m %
. . .
Y1 = PolyApprox(S_initial1,S1,flag1,bound1);
Y2 = PolyApprox(S_initial1,S2,flag2,bound2);
. . .
% End of script %
system('main.exe') % run exe
  4 个评论
Ilias Seferlis
Ilias Seferlis 2017-12-27
you are right. Do you have any idea how I can make this work? Is it even possible? Thanks!
Walter Roberson
Walter Roberson 2017-12-28
Why not convert your script to a function? Especially considering that you plan to compile it, you surely cannot be counting on it changing variables in whatever workspace it happens to be executing in ?

请先登录,再进行评论。

回答(1 个)

Matt J
Matt J 2017-12-27
编辑:Matt J 2017-12-28
If your "script" really is a script (i.e., no function line header), then I'm not sure the Matlab Compiler will accept that as your main file. If you convert main.m to an actual M-function file, there's no reason why a sub-function should present problems.

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by