Deployed App from App Designer cannot call function

Hi,
I have developed an App in the App Designer that reads an input text file and creates an ode file for simulation with ode45. The parsing of the text input file works fine, but once the m-file that contains the model has been created, the standalone app designer cannot find it (I guess because it was not there when the App was compiled).
Is there a way to facilitate this, i.e. to call a function that was created on-the-fly? For clarity: The compiled standalone App runs fine up to the point where the m-file with the model needs to be integrated. At that point it crashes, saying that it cannot find the m-file.
From within Matlab my App runs fine, by the way. It's just that I would like to share this with users who do not have matlab installed on their machine.
Thanks a lot for your help!
Hans

 Accepted Answer

Is there a way to facilitate this, i.e. to call a function that was created on-the-fly?
No. From the documentation "MATLAB Runtime only works on MATLAB code that was encrypted when the deployable archive was built. Any function or process that dynamically generates new MATLAB code will not work against MATLAB Runtime."
If the input data file contains values for parameters that should be passed into a standard ODE function (essentially Mad Libs style) you may be able to use the techniques described here to have a standard ODE function and pass the data from the files in.
[a, b, c] = readDataFromFile(theFilename);
myodefun = @(t, y) standardODEFile(t, y, a, b, c);
% call ode45 with myodefun as the first input

1 Comment

Clear. Thanks.
I may try another solution that I thought of yesterday, i.e. parsing the input text file that contains the ODE's to a function f that gives me a vector with the derivatives, such as
f=@(t,x) [x(1)+x(2); x(1)-x(2)];
To create this function I will use str2func (after obtaining the formulaes on the RHS of the ODE from file), I think this will work.
Regards, Hans

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Products

Asked:

on 26 May 2021

Commented:

on 27 May 2021

Community Treasure Hunt

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

Start Hunting!