I'm trying to generate Buttons programmatically with the App Designer.
I have an Excel File, where all the names of the Buttons are listet, not knowing how many Buttons (or lines in Excel) will be needed.
I figured out how to create components with the App Designer programmtically:
So I tried many things, but none of them worked.
The problem is, that (as far as I understood) every Button (or other element) in the GUI needs his own variable. So I have to create new variables with the function eval, wich is, how I found out on every site here, absoulutly forbidden...
My first thought was to create an Array, but it didn't work:
Unable to perform assignment because dot indexing is not supported for variables of this type.
And heres the Code:
A = [378 700 100 22];
allKeys = string(keys(CellContOne));
UniButton = zeros(length(allKeys));
for i = 1:length(allKeys)
UniButton(i) = uibutton(app.UIFigure, 'state');
UniButton(i).Position = A;
UniButton(i).Text = allKeys(i);
b_text = UniButton(i).Text;
b_value = UniButton(i).Value;
UniButton(i).ValueChangedFcn = @app.mybuttonpress;
A(2) = A(2) -25;
I also tried using just one variable for every Button, but it didn't work because the GUI wasn't able to figure out wich button was pressed (I need this information for the callback) The code looks the same, just without the index (i) and the line UniButton = zeros(length(allKeys));
Structures and Cell Arrays also didn't work for me.
I hope You can help me!