Effacer les filtres
Effacer les filtres

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?

4 vues (au cours des 30 derniers jours)
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.

Réponses (1)

Walter Roberson
Walter Roberson le 6 Avr 2016
A_data = get(matrix,'Data');
  1 commentaire
Chris Gnam
Chris Gnam le 6 Avr 2016
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?

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by