How do I change the dimensions of a UItable through edit field boxes?

2 views (last 30 days)
I am wanting to use the edit field boxes to change the rows and columns of the UI table I have in my GUI. I have set the first edit field box to the number of rows (labeled n) and the second field box for the number of columns (labelled m). I have a pushbutton labelled insert that should take the values of n and m and create the table from those values.
However I get this error "The class handle has no Constant property or Static method named 'UItable'." when I use handles to refer to the table. Is there a mistake that I have done to refer to the table incorrectly?
Below is the code I have on the pushbutton callback.
Nrows = app.n; %app.n from edit field box 1 callback
Ncolumns = app.m; %app.m from edit field box 2 callback
set(handle.UItable,cell(Nrows,Ncolumns)); %error occurs here - most likely this entire line is wrong
Any help would be appreciated.

Answers (1)

Reshma Nerella
Reshma Nerella on 18 Jun 2021
Hi,
I understand that you want to take the number of rows and columns as inputs from edit boxes and create a table of that size.
Here's an example
rows = app.EditField.Value;
cols = app.EditField2.Value;
vars = repmat("double",1,cols); % Variable types for all columns, I chose double for example.
t = table('Size',[rows,cols],'VariableTypes',vars);
app.UITable.Data = t;
When you do it this way, you should also be mentioning about the variable type for each column while creating variable 't'.
Hope this helps!

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!