- If you are able to save the needed variables into .mat file, you can use save and load functions to share the data between App Designer and Simulink. If you run lots of simulations, then second method is faster, it's better in general
- In your script, get the handles of your app using this answer. This way, you have access to the app and all the components and public properties and methods.
Unrecognized function or variable in app designer
18 views (last 30 days)
I would like to run a Matlab script from an App, but i get the error "unrecognized funtion or variable simduration".
In the app, I use 2 buttons. One for assigning values to the base workspace and one to run the script "zwembad_model_app".
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: runsimulationButton
function runsimulationButtonPushed(app, event)
%simout = sim("test_app","StopTime",num2str(app.DurationEditField.Value));
% Button pushed function: SaveParametersButton
function SaveParametersButtonPushed(app, event)
This is the code from the matlab script (I'm aware that this line of code can be simply integrated in the app code and that works fine but later on I want to expand the script).
simout = sim("test_app","StopTime",num2str(simduration));
When running the app I can see the variables getting stored in de base workspace when the Saveparameters button is activated, but when I press the runsimulation button I get the error. When running the script seperately (after pressing saveparamters button in the app), there is no problem.
I'm not experienced in working with app designer so I hope there is some simple solution I overlooked.
Any help will be appreciated!
Mario Malic on 6 Mar 2021
I am not to familiar with Simulink files, but you can try following:
Friendly reminder from all of us here, avoid assignin and similar functions.