필터 지우기
필터 지우기

Assigning array-type names to elements of a GUI or App

조회 수: 3 (최근 30일)
Saeid
Saeid 2021년 12월 26일
댓글: Matt J 2021년 12월 26일
How can I assign names coming from a string array to the elements of an App?
Example: I have the following string array
CBNames= ["NameCheckBox" "PhoneCheckBox" "AddressCheckBox"]
Now, when trying to change the Value property of the PhoneCheckBox in may App, I would like to refer to it as:
app.CBNames(2).Value=1
But when I try this I receive an error message that says:
Unrecognized method, property, or field 'CBName' for class 'MAINApp'
Is there a way to do this or is this categorically impossible in Matlab?

채택된 답변

Matt J
Matt J 2021년 12월 26일
app.(CBNames(2)).Value=1
  댓글 수: 3
Saeid
Saeid 2021년 12월 26일
By the way, is there a way to refer to more than one element in one command?
Something like:
app.(CBNames(1:4)).Value=1
Matt J
Matt J 2021년 12월 26일
You could create a property which stores a vector of handles to your checkboxes.
app.checkboxes=arrayfun(@(el)app.(el), CBNames);
Then, you can manipulate them as a group by doing things like,
set(app.checkboxes,'Value',1)
set(app.checkboxes,{'Value'},{1,0,1,0}')

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by