- 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
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Yari Van Hecke
am 6 Mär. 2021
Kommentiert: Yari Van Hecke
am 18 Mär. 2021
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));
zwembad_model_app
plot(app.UIAxes,simout.watertemperatuur.Time,simout.watertemperatuur.Data);
end
% Button pushed function: SaveParametersButton
function SaveParametersButtonPushed(app, event)
assignin("base","simduration",app.DurationEditField.Value);
assignin("base","lengte",app.lengteEditField.Value);
assignin("base","breedte",app.breedteEditField.Value);
assignin("base","diepte",app.diepteEditField.Value);
assignin("base","start_temperatuur",app.starttemperatuurEditField.Value);
assignin("base","U_bodem",app.U_bodemEditField.Value);
assignin("base","U_wand",app.U_wandEditField.Value);
assignin("base","U_cover",app.U_coverEditField.Value);
assignin("base","opticalefficiency",app.opticalefficiencyEditField.Value);
assignin("base","a1",app.heatlosscoefficientlinearEditField.Value);
assignin("base","a2",app.heatlosscoefficientquadraticEditField.Value);
assignin("base","Ac",app.collectorsurfaceEditField.Value);
assignin("base","serie",app.serieEditField.Value);
assignin("base","parallel_test",app.parallelEditField.Value);
assignin("base","min_temperature_gain",app.mintemperaturegainEditField.Value);
end
end
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!
0 Kommentare
Akzeptierte Antwort
Mario Malic
am 6 Mär. 2021
Hello,
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!