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

6 ビュー (過去 30 日間)
Caleb Schindler
Caleb Schindler 2020 年 3 月 24 日
回答済み: Mehdi Ansarey 2025 年 2 月 17 日 16:03
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 日 16:03
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 Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by