Convert to array/cell

조회 수: 1 (최근 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
Degaulle
Degaulle 2023년 5월 1일
Thanks!
Jon
Jon 2023년 5월 1일
Your welcome - that was interesting

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by