Taking user input from table in GUI

16 次查看(过去 30 天)
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 个评论
Chris Dan
Chris Dan 2020-6-5
The data is entered into the table when I press a push button.
After that, I cannot take user input in the table

请先登录,再进行评论。

采纳的回答

Chris Dan
Chris Dan 2020-6-6
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by