How do I change the dimensions of a UItable through edit field boxes?
4 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Reshma Nerella
2021-6-18
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!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!