Using matlabFunction to run solve() in a deployed app
5 次查看(过去 30 天)
显示 更早的评论
Hi. I'm trying to use matlabFunction to run solve() statements, so the app will be deployed fine. I have this example code:
if ~isdeployed()
syms x
eq = solve(x + 5 == 8, x);
fun = matlabFunction(eq, 'File', 'SolveTest.m');
clear x eq fun
else
fun = @SolveTest;
end
app.EditField.Value = SolveTest;
it works fine inside appdesigner, but when I try to deploy it by 'deploytool', I get this error:
Warning: In "test.mlapp", "syms" are excluded from packaging for the MATLAB Runtime environment according to the MATLAB Compiler license. Either remove the file or function from your code, or use the MATLAB function "isdeployed" to ensure the function is not invoked in the deployed component.
how can it be fixed?
I'm using R2022b.
0 个评论
回答(1 个)
Ayush Singh
2024-7-10
Hey Mahdi!
The approach you are taking is correct in using `isdeployed` to differentiate between development and deployment environments. However, you need to ensure that the symbolic operations and the creation of the function file happen only in the development environment.
You can try the modified version of your code, ensuring that symbolic operations and function file generation are only executed in the development environment:
if ~isdeployed()
% Symbolic operations and function file generation
syms x
eq = solve(x + 5 == 8, x);
matlabFunction(eq, 'File', 'SolveTest.m'); % Create the function file
clear x eq
end
% Load the generated function
fun = @SolveTest;
app.EditField.Value = fun();
Ensure that the Generated Function File is Included in the Deployment:
- Make sure that the generated function file 'SolveTest.m' is included in the files to be deployed. You can do this in the deploytool by manually adding 'SolveTest.m' to the list of files to be packaged.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 MATLAB Compiler SDK 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!