Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
Johnny Birch
Johnny Birch el 16 de Mayo de 2020
Editada: Johnny Birch el 16 de Mayo de 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

Respuestas (0)

Categorías

Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by