I need help with uitable in gui

조회 수: 3 (최근 30일)
Hamza
Hamza 2016년 4월 28일
편집: Hamza 2016년 5월 5일
Hi I need to know how to transfer data between two uitables in MATLAB like this: Select cell from table1 one then click push button then generate new row in table 2 consists data of the selected row in table 1 Also I need to know how I can delete data of selected row in uitable using push button
  댓글 수: 2
Jan
Jan 2016년 4월 28일
What have you tried so far? Which problems occur? If you post your code, we can easily suggest improvements. But when we guess, what you want, it is unlikely, that the suggestions meet your problem accurately enough.
Hamza
Hamza 2016년 4월 30일
I just need to know how

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2016년 5월 4일
You need to configure a uitable CellSelectionCallback . When the callback fires, the second parameter will be a structure that contains the indices of the cells that are selected. You do not need to act on the information immediately, but you might need to record it for later use.
To get the selected cells after that requires using Java methods that are undocumented by Mathworks and which are being changed. You can find those described at undocumentedmatlab.com
  댓글 수: 1
Hamza
Hamza 2016년 5월 4일
편집: Hamza 2016년 5월 5일
thank you very much i solved it using selection callback
global x
idx = eventdata.Indices;
table = get(hObject,'Data');
x=table(idx(1,1):idx(end,1),idx(1,2):idx(end,2));
then used pushbutton to put value of x into uitable2

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2016년 4월 28일
Try something like this (untested)
% Read both tables
data1 = handles.uitable1.Data;
data2 = handles.uitable2.Data;
% Transfer over data from 1 to 2
data2(row1:row2, col1:col2) = data1(row1:row2, col1:col2);
% Send updated variable back to table 2
handles.uitable2.Data = data2;
  댓글 수: 3
Image Analyst
Image Analyst 2016년 4월 30일
I don't know if there is a property to say what the user has highlighted in the table, if anything. You can check for properties like handles.uitable2.Selection or handles.uitable2.Value or things like that. You can list all properties and methods like this:
properties(handles.uitable1)
methods(handles.uitable1)
Hamza
Hamza 2016년 5월 4일
Where should I type these commands

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by