Convert to array/cell

2 次查看(过去 30 天)
Degaulle
Degaulle 2023-5-1
评论: Jon 2023-5-1
I'm building an app using app designer and I have these chunks of code:
function CheckBoxValueChanged(app, event)
value = app.CheckBox.Value;
if get(app.CheckBox,'value')
set(app.Spinner, 'Visible','on')
set(app.Spinner, 'Enable','on')
end
end
function CheckBox2ValueChanged(app, event)
value = app.CheckBox2.Value;
if get(app.CheckBox2,'value')
set(app.Spinner2, 'Visible','on')
set(app.Spinner2, 'Enable','on')
end
end
function CheckBox3ValueChanged(app, event)
value = app.CheckBox.Value;
if get(app.CheckBox3,'value')
set(app.Spinner3, 'Visible','on')
set(app.Spinner3, 'Enable','on')
end
end
I want to know how can i simplify the code(for example: using arrays or something similar)

采纳的回答

Jon
Jon 2023-5-1
Define one function to do the work, and then call this same function from each of the callbacks
  7 个评论
Jon
Jon 2023-5-1
Your welcome - that was interesting

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by