Hi,
I want that my programm enables different EditFields in App designer on the basis of a variable a. The names of the EditFields are stored in a cell array.
a=2;
EditFieldList={app.EditField1.Enable,app.EditField2.Enable,app.EditField3.Enable}
for z=1:1:a
EditFieldList{z}=1;
end
The code isn't working because i can't access the the variable names itself but only the output (in this case [off]).
Is there a way to be able to activate/deactivate the EditFields in a loop?

 採用された回答

Rik
Rik 2022 年 3 月 24 日

1 投票

I suspect this is what you need. I don't know if this works in AppDesigner, but this is how it normally works in Matlab:
a=2;
EditFieldList={app.EditField1,app.EditField2,app.EditField3};
for z=1:a
EditFieldList{z}.Enable=1;
end
You could even try setting it without a loop if you use an array of objects instead of a cell array:
EditFieldList=[app.EditField1,app.EditField2,app.EditField3];
set(EditFieldList(1:a),'Enable',1)

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

質問済み:

2022 年 3 月 24 日

回答済み:

Rik
2022 年 3 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by