Unrecognized function or variable in app designer
Show older comments
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!
Accepted Answer
More Answers (0)
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!