Taking user input from table in GUI

22 Ansichten (letzte 30 Tage)
Chris Dan
Chris Dan am 5 Jun. 2020
Beantwortet: Chris Dan am 6 Jun. 2020
Hello,
Sorry for the long post. I have this GUI, I am working on in this gui. I have this table
I made this table using these lines:
Boundary_Position = 0;
AssemblyData4 = {0, 0};
AssemblyTable4 = uitable (f, 'Units' , ' centimeters' , 'Position' , [13,0,5,5], 'Data' , AssemblyData4, 'ColumnEditable' , [true, true], 'ColumnName' , { ' Nodes / mm ' ; ' Boundary ' }, ' CellEditCallback ' , {@ AssemblyEdit_Callback4});
Now to put data in the table,
I am using this loop
for TempIndex2 = 1: size (GlobalMesh, 2)
AssemblyData4 (TempIndex2,1) = num2cell (GlobalMesh (1, TempIndex2));
AssemblyData4 {TempIndex2,2} = 0;
end
set (AssemblyTable4, 'Data' , AssemblyData4);
Global Mesh is the list of nodes, after I enter data, the picture looks like this
After this the user enters the value in the bounary column, and the picture becomes
To save this data from the user, the code I am using is
function AssemblyEdit_Callback4 (source, eventdata, handles)
for TempIndex3 = 1: size (GlobalMesh, 2)
Boundary_Position (TempIndex3) = AssemblyData4 {TempIndex3,2};
% Boundary_Position (TempIndex3) = get (handles.AssemblyTable4, 'data');
end
end
Boundary_Position is a global variable.
The problm I am having is that no data is being stored in the variable Boundary_Position. It is empty
Does anyone know what could be changed or how it can be done?
  1 Kommentar
Chris Dan
Chris Dan am 5 Jun. 2020
The data is entered into the table when I press a push button.
After that, I cannot take user input in the table

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Chris Dan
Chris Dan am 6 Jun. 2020
I solved it.
function AssemblyEdit_Callback4(source, eventdata, handles)
Boundary_Position= get(AssemblyTable4, 'data');
display(Boundary_Position)
end
A single line of code......no for loop

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by