One part of my uicontrol application display a series of parameters from an INI-file that can be modified. For each I want to display generate a row consisting of one uilabel, uitextbox, uibutton each. This is what it looks like:
I also want to display only a set of parameters based on the section of the INI config file (e.g. [Paths], [Limits]). The section can be changed via a dropdown combobox (not shown here). This means the number of rows/parameters changes during runtime and I need to create or destroy rows depending on the number of paramters, also during runtime (i always destroy all rows before creating the new amount of new rows):
arrData = ini.GetParameters();
I choose to create the controls dynamically and in the form of an array. This way I can loop through the controls and initialize each row, e.g. set parameter label titles and values. Here is the minimum code example for the generation of the labels (same with button and edit):
arrLbls = matlab.ui.controls.uilabel.Empty(num_array);
arrLbls(i) = uilabel(parent, "Specific Label Title");
The code works fine but is slow. Execution takes up to 30 seconds, although only when up to 15 - 20 parameters (=sum of 3 x 20 controls) are generated. While this may make sense due to the high number of controls - spread over three arrays - the deletion of the controls is also pretty slow, altough the code is pretty simple:
The two lines above require up to 10 - 20 seconds.
Is there a way to increase the speed of my code? Is there a function like C realloc() which lets me expand/shink the array?
(Please excuse any errors you may spot but I only have access to Matlab at work and typed the code off my memory.)