Filter löschen
Filter löschen

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

1 Ansicht (letzte 30 Tage)
Johnny Birch
Johnny Birch am 16 Mai 2020
Bearbeitet: Johnny Birch am 16 Mai 2020
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

Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by