Compiled code to use str2func to call an application (mlapp file) fails while the same code works in the MATLAB environment
2 ビュー (過去 30 日間)
古いコメントを表示
I use str2func to allow the same code to call different graphics applications. Code snippet below
graphicsApp= str2func([g, 'Plot']);
% app.hTemp = graphicsApp(app, app.tsurf, app.p,...
% app.nPlots.(g), app.userFilePath);
app.hTemp = HBCPlot(app, app.tsurf, app.p,...
app.nPlots.(g), app.userFilePath);
Both versions of code work in the MATLAB environment as expected, but the commented code never opens the graphics application, "HBCPlot", in the particular instance where g='HBC'. It's easy enough to work around this particular block of code, but I subsequently use the graphics handles elsewhere so I've got to get this to work. I've examined the handle of course, @HBCPlot, and given the code works in the native environment I'm at a loss.
I wrote a simple test case, code below:
Teststr2fcn(1);
name=['Test','str2fcn'];
hTeststr2fcn= str2func(name);
hTeststr2fcn(2);
When this code is compiled both instances of Teststr2fcn appear
0 件のコメント
採用された回答
Jan
2023 年 2 月 7 日
編集済み: Jan
2023 年 2 月 7 日
A bold guess: Is HBCPlot() included in the compiled application? If its name is hidden, Matlab cannot guess, that it has to be included. I'm not sure if "I've examined the handle of course, @HBCPlot" means exactly this problem.
Maybe this is a cleaner solution:
switch g
case 'HBC'
PlotFcn = @HBCPlot;
otherwise
error('Unknown plot function');
end
app.hTemp = plotFcn(app, app.tsurf, app.p,...
app.nPlots.(g), app.userFilePath);
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で MATLAB Compiler についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!