Using matlabFunction to run solve() in a deployed app
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Ayush Singh
le 10 Juil 2024
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 commentaires
Voir également
Catégories
En savoir plus sur MATLAB Compiler SDK dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!