필터 지우기
필터 지우기

Loop through grid layout takes FOREVER. How can I optimize the code?

조회 수: 1 (최근 30일)
Johnny Birch
Johnny Birch 2020년 5월 16일
편집: Johnny Birch 2020년 5월 16일
I am trying to create an app with many text areas (80x12) in a gridlayout. I want to fill each grid with a individual text taken from a cell array. However, in the code example below I am just using {['test1',newline,'test2']} for all of them. But in the real example each text.value is different. I am looping over each textarea in the gridlayout and it is working as intended. However, it takes FOREVER (75.101076 seconds). Is there a way to speed up the process?
tic
fig = uifigure('Position',[100 100 440 320]);
%fig.WindowState = 'maximized';
g = uigridlayout(fig,[80 12],'Scrollable','on');
g.ColumnSpacing = 0;
g.RowSpacing = 0;
g.ColumnWidth = {150,50,20,50,150,50,50,50,50,50,150,'fit'};
g.RowHeight = {50,50,50,50,50,50,50,50,50,50,...
50,50,50,50,50,50,50,50,50,50,...
50,50,50,50,50,50,50,50,50,50,...
50,50,50,50,50,50,50,50,50,50,...
50,50,50,50,50,50,50,50,50,50,...
50,50,50,50,50,50,50,50,50,50,...
50,50,50,50,50,50,50,50,50,50,...
50,50,50,50,50,50,50,50,50,50};
for j = 1:12
for i = 1:80
txa = uitextarea(g,'Value', {['test1',newline,'test2']});
txa.Layout.Row = i;
txa.Layout.Column = j;
if i == 3
txa.BackgroundColor = 'yellow';
end
if i == 8 && j == 5
txa.BackgroundColor = 'green';
end
end
end
toc
Elapsed time is 75.101076 seconds.
Below is an example of the output

답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by