How can I get this simple gui to allow the user to input data into a table, then save that input once they close the window?

3 次查看(过去 30 天)
What I'd like to have happen is that the user defines the size of a square matrix (for instance, 2 x 2). Then a new window would pop up and ask them for the individual data points, and then they would input the values into the correct spots on a table of the right size. I have gotten this to work fine up until the point where I actually need to retrieve the data to be used later. I cannot seem to "save" the data the user inputs. Here is what I have so far:
input = char(inputdlg('Please enter the order of the square matrix you wish to enter:'))
n = str2num(input)
matrix_data = cell(n,n)
matrix_input = figure('MenuBar','none','ToolBar','none',...
'Name','Row Reduction Assistant','NumberTitle','off','Position', [400 350 300 300]);
matrix = uitable(matrix_input,'Data',matrix_data,...
'Position', [42 65 220 220],...
'ColumnEditable',true(1,10),...
'ColumnName',[],...
'ColumnWidth', {30},...
'FontSize', 15,...
'RowName',[]);
waitfor(gcf)
A_data = get(matrix_data,'Data');
When I do this, I get the error message:
Error using get
Conversion to double from cell is not possible.
Error in Test_file (line 14)
A_data = get(matrix_data,'Data');
Please note that what I've got there isn't "neat" as far as GUI's go. I just threw together the basic structure, but I can't seem to figure out how to store the data.

回答(1 个)

Walter Roberson
Walter Roberson 2016-4-6
A_data = get(matrix,'Data');
  1 个评论
Chris Gnam
Chris Gnam 2016-4-6
This was what I originally tried, however that also does not work. When I replace my line of code with yours, what I get is:
Error using matlab.ui.control.Table/get
Invalid or deleted object.
Error in Test_file (line 14)
A_data = get(matrix,'Data');
Any idea of another solution? Or what else can be done?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by