How can I bring values from components of app designer into a matlab script that configures simulink models and is started by app designer?

4 次查看(过去 30 天)
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?

回答(1 个)

Divyanshu
Divyanshu 2023-2-21
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'->

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by