Can not use arrays of ui components in app desiger
19 次查看(过去 30 天)
显示 更早的评论
I am using the app designer to create an app with quite a lot of properties here is a smal sample:
MemValue_1_1 matlab.ui.control.EditField
MemValue_1_2 matlab.ui.control.EditField
MemValue_1_3 matlab.ui.control.EditField
MemValue_1_4 matlab.ui.control.EditField
MemValue_1_5 matlab.ui.control.EditField
MemValue_1_6 matlab.ui.control.EditField
MemValue_1_7 matlab.ui.control.EditField
MemValue_1_8 matlab.ui.control.EditField
MemValue_1_9 matlab.ui.control.EditField
MemValue_1_10 matlab.ui.control.EditField
MemValue_1_11 matlab.ui.control.EditField
MemValue_1_12 matlab.ui.control.EditField
MemValue_1_13 matlab.ui.control.EditField
MemValue_1_14 matlab.ui.control.EditField
MemValue_1_15 matlab.ui.control.EditField
MemValue_1_16 matlab.ui.control.EditField
MemValue_1_17 matlab.ui.control.EditField
MemValue_1_18 matlab.ui.control.EditField
MemValue_1_19 matlab.ui.control.EditField
MemValue_1_20 matlab.ui.control.EditField
MemValue_1_21 matlab.ui.control.EditField
MemValue_1_22 matlab.ui.control.EditField
MemValue_1_23 matlab.ui.control.EditField
MemValue_1_24 matlab.ui.control.EditField
MemValue_1_25 matlab.ui.control.EditField
MemValue_1_26 matlab.ui.control.EditField
MemValue_1_27 matlab.ui.control.EditField
MemValue_1_28 matlab.ui.control.EditField
MemValue_1_29 matlab.ui.control.EditField
MemValue_1_30 matlab.ui.control.EditField
MemValue_1_31 matlab.ui.control.EditField
MemValue_1_32 matlab.ui.control.EditField
MemValue_1_33 matlab.ui.control.EditField
MemValue_1_34 matlab.ui.control.EditField
MemValue_1_35 matlab.ui.control.EditField
MemValue_1_36 matlab.ui.control.EditField
MemValue_1_37 matlab.ui.control.EditField
MemValue_1_38 matlab.ui.control.EditField
MemValue_1_39 matlab.ui.control.EditField
MemValue_1_40 matlab.ui.control.EditField
MemValue_1_41 matlab.ui.control.EditField
MemValue_1_42 matlab.ui.control.EditField
MemValue_1_43 matlab.ui.control.EditField
MemValue_1_44 matlab.ui.control.EditField
MemValue_1_45 matlab.ui.control.EditField
MemValue_1_46 matlab.ui.control.EditField
MemValue_1_47 matlab.ui.control.EditField
MemValue_1_48 matlab.ui.control.EditField
MemValue_1_49 matlab.ui.control.EditField
MemValue_1_50 matlab.ui.control.EditField
MemValue_1_51 matlab.ui.control.EditField
MemValue_1_52 matlab.ui.control.EditField
MemValue_1_53 matlab.ui.control.EditField
MemValue_1_54 matlab.ui.control.EditField
MemValue_1_55 matlab.ui.control.EditField
MemValue_1_56 matlab.ui.control.EditField
MemValue_1_57 matlab.ui.control.EditField
MemValue_1_58 matlab.ui.control.EditField
MemValue_1_59 matlab.ui.control.EditField
MemValue_1_60 matlab.ui.control.EditField
MemValue_1_61 matlab.ui.control.EditField
MemValue_1_62 matlab.ui.control.EditField
MemValue_1_63 matlab.ui.control.EditField
MemValue_1_64 matlab.ui.control.EditField
It should be very obvious that this is bad code and I would like to use an array of MemValues but sadly due to the restrictions of the app designer I can not do that since I would need to modify the code that is not editable in the app designer. Is there any way to solve this issue?
Btw: I know that I can export to .m file where I could do that but I can not reconvert that to the .mlapp file
0 个评论
采纳的回答
Voss
2024-6-21
One thing you can do is construct the array of components in the app's startupFcn, e.g.:
N = 64;
app.MemValue = gobjects(1,N);
for ii = 1:N
app.MemValue(ii) = app.(sprintf('MemValue_1_%d',ii));
end
A new app property (here it's called 'MemValue') would also have to be added.
5 个评论
Adam Danz
2024-6-24,14:53
> Is there any way to unlock the app designer to be able to edit Code in all places?
Not currently in R2024a or any previous release.
Voss
2024-6-24,15:21
编辑:Voss
2024-6-24,15:25
"the fundamental problem is, that you can not edit any code inside the createComponents in the AppDesigner CodeView"
@Moritz: I thought the problem was that you "would like to use an array of MemValues". You can do that. Let App Designer create the components one at a time as it does (using properties MemValue_1_1, MemValue_1_2, etc.), and in your startupFcn construct an array of those components, as shown in my answer.
更多回答(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!