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 visualizaciones (últimos 30 días)
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?

Respuestas (1)

Divyanshu
Divyanshu el 21 de Feb. de 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'->

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by