Select EditField with a FOR loop in Matlab app designer
5 次查看(过去 30 天)
显示 更早的评论
Hi all, I'm developing a small GUI to display data read via serial. In my app, I'll have a large number of EditFields, which I'll fill and move from time to time depending on other view settings. I will have a large number of these fields, specifically 64, I was wondering if there was any way to select them using a FOR loop. In the example below:
.
.
.
app.EditField_8_1.Position = [21+(88*0),21+(88*0),87,87];
app.EditField_8_2.Position = [21+(88*1),21+(88*0),87,87];
app.EditField_8_3.Position = [21+(88*2),21+(88*0),87,87];
app.EditField_8_4.Position = [21+(88*3),21+(88*0),87,87];
app.EditField_8_5.Position = [21+(88*4),21+(88*0),87,87];
app.EditField_8_6.Position = [21+(88*5),21+(88*0),87,87];
app.EditField_8_7.Position = [21+(88*6),21+(88*0),87,87];
app.EditField_8_8.Position = [21+(88*7),21+(88*0),87,87];
app.EditField_7_1.Position = [21+(88*0),21+(88*1),87,87];
app.EditField_7_2.Position = [21+(88*1),21+(88*1),87,87];
app.EditField_7_3.Position = [21+(88*2),21+(88*1),87,87];
app.EditField_7_4.Position = [21+(88*3),21+(88*1),87,87];
app.EditField_7_5.Position = [21+(88*4),21+(88*1),87,87];
app.EditField_7_6.Position = [21+(88*5),21+(88*1),87,87];
app.EditField_7_7.Position = [21+(88*6),21+(88*1),87,87];
app.EditField_7_8.Position = [21+(88*7),21+(88*1),87,87];
.
.
.
is it possible to select the various EditFields using a syntax like
app.EditField_i_j.Position = ...
to manage them with a FOR loop? does anyone know the syntax?
A thousand thanks!
0 个评论
回答(1 个)
Cameron
2022-12-22
Generally speaking, I don't think this is good practice, but here is a way you can do what you want. You may have to adapt it to your variable names, but that's one way to do it.
for xx = 1:8
eval(strcat('app.EditField_8_',num2str(xx),...
'.Position = [21+88*',num2str(xx-1),',21+88*',...
num2str(xx-1),',',num2str(87),',',num2str(87),'];'))
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!