Predefine UI components (App Designer)
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I am making an app which generates all the components depending on an Excel-File.
It does work and the App is running, but Matlab keeps giving me the warning, that predefining the Components would be more efficent, because they're expanding in a loop.
One example for all the Switches I generate is below.
Commands like zeros(..) do not work, because afterwards the code doesn't work because of dot indexing ore something like that.
I hope that predefining the Components would be better for the performance for my app, but I don't know how..
I hope someone can help me - thank you very much!
Code example:
for i = 1:length(allKeysOne) %For Loop to create the Check Boxes
j = (ContPos(ContType(allKeysOne(i))));
%%% Label %%%
UniSwLabel(i) = uilabel(Tabs(TabNames(ContType(allKeysOne(i))))); %Creating a CheckBox
UniSwLabel(i).HorizontalAlignment = 'center';
UniSwLabel(i).FontSize = 14;
UniSwLabel(i).FontWeight = 'bold';
UniSwLabel(i).Text = allKeysOne(i); %Giving the CheckBox it's Text
ContSwNr(allKeysOne(i)) = i;
%%% Components %%%
UniSw(i) = uiswitch(Tabs(TabNames(ContType(allKeysOne(i)))), 'slider');
UniSw(i).ValueChangedFcn = @app.switchswitched; %Callback function
UniSw(i).FontSize = 16;
UniSw(i).Tag = allKeysOne(i);
UniSw(i).FontWeight = 'bold';
%%% ....%%%
end
0 个评论
回答(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!