Taking user input from table in GUI

조회 수: 23 (최근 30일)
Chris Dan
Chris Dan 2020년 6월 5일
답변: Chris Dan 2020년 6월 6일
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