How to extract a app designer component from an array and change its properties

조회 수: 4 (최근 30일)
I currently have an issue where I have a 1x64 array of app designer components (lamps) and I want to be able to index the matrix then change the color of the lamp however Im unsure how to alter the lamp color after extracting it from the matrix.
example
D=[app.A1, app.B2, app.C3]
Desired_Lamp=D(1,Desired_Column)

답변 (2개)

Harsha Priya Daggubati
Harsha Priya Daggubati 2020년 3월 27일
Hi,
I guess you can use Property Inspector to know the properites of any variable present in the workspace. If it has any properties you can refer using '.' . I think it should go well. If not, can you share these variables so that I can investigate the issue with more clarity.
  댓글 수: 2
Caleb Schindler
Caleb Schindler 2020년 4월 6일
Hello,
Here's my issue in more depth/ with the attached code. What I want to do in the end would be to change the color of a lamp based on the Guess value. In the attached code I have managed to specify an Index value (1-64) corrisponding to what position in array C my Guess value is in. Where im stuck is how to then associate that Index value with a lamp component then change its color.
Thanks for you help!
Guess=app.TargetCallout.Text
C={'A1','A2', 'A3','A4' ,'A5' ,'A6','A7', 'A8', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'C1', 'C2', 'C3', 'C4' ,'C5' ,'C6' ,'C7' ,'C8' ,'D1' ,'D2','D3','D4', 'D5', 'D6', 'D7', 'D8', 'E1', 'E2', 'E3', 'E4', 'E5', 'E6', 'E7', 'E8', 'F1', 'F2','F3' ,'F4' ,'F5' ,'F6' ,'F7' ,'F8' ,'G1' ,'G2', 'G3', 'G4', 'G5', 'G6', 'G7', 'G8', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7','H8'}
IndexC=strfind(C,Guess)
Index=find(not(cellfun('isempty',IndexC))) % This specifies a number ie A1 would be Index= 1, H8 = 64
Harsha Priya Daggubati
Harsha Priya Daggubati 2020년 4월 7일
Hi,
I understood you want to change Color property of your Lamp component using Index.But, It is very difficult to guess to guess what Lamp component would be and its properties are. It would help if you can share your Lamp component.

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


Mehdi Ansarey
Mehdi Ansarey 2025년 2월 17일
One strategy in these situations is indexing your components using Tag or Userdata.
e.g: you have some components i.e lamp and assign each a unique number in Tag.
then you can find desired lamp (that match your input guess) by its Tag
DesiredLamp= findall(app, Tag= ""+ i);
now process found Lamp

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by