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!