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 Center および File ExchangeDevelop 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