
How can I bring values from components of app designer into a matlab script that configures simulink models and is started by app designer?
3 views (last 30 days)
Show older comments
Hello,
my aim is to design an app as a GUI in app designer that can be used to configure and start some matlab scripts to run and evaluate a simulink model. Because I want to have the possibility to change parameters that are used in the script/simulink model via GUI (graphic user interface designed in app designer), I have to bring these values from the app designer components into the matlab script. I already tested to implement that with properties (access = public), but it didn't work.
Does anyone have an idea how to do this as smartly as possible?
0 Comments
Answers (1)
Divyanshu
on 21 Feb 2023
I have created a demo App using AppDesigner and a demo model in Simulink whose block parameters I am updating from the App itself. Here is the Code View of App->
methods (Access = private)
% Code that executes after component creation
function init(app)
app.a = 5;
end
% Button pushed function: LaunchModelButton
function launchModel(app, event)
launchModel(app.a);
end
% Value changed function: Gain_ParamEditField
function update_prop_a(app, event)
value = app.Gain_ParamEditField.Value;
app.a = value;
end
end
Here is the MATLAB script ‘launchModel’->
function launchModel(a)
k = int2str(a);
open_system('demoModel1');
set_param('demoModel1/Gain','Gain',k);
open_system('demoModel1/Scope');
sim('demoModel1');
end
Here is the model 'demoModel1'->

0 Comments
See Also
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!