How to remove a row from a Table in the GUI

조회 수: 2 (최근 30일)
Paul Nanfah
Paul Nanfah 2015년 6월 15일
댓글: Paul Nanfah 2015년 6월 15일
Hey everybody,
I try to remove a row from the iutable
I wrote the code to add as following :
% --- Executes on button press in add. function add_Callback(hObject, eventdata, handles) data = get(handles.uitable1, 'data'); data(end+1,:) = 0; set(handles.uitable1, 'data', data)
and from it, i derived the code to remove:
function remove_Callback(hObject, eventdata, handles) data = get(handles.uitable2, 'data'); data(end-1,:)= 0; set(handles.uitable2, 'data', data)
I then get the following error statment:
what I am doing wrong here ?
I initialize the Tables values wih a zero matrix a=zeros(3,4). do I need first to delete the last line of a ?
Thank you Paul
  댓글 수: 1
Henric Rydén
Henric Rydén 2015년 6월 15일
Please format your code.
It seems that you have code for two uitables, uitable1 and uitable2 , but there is only one in the image.

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

채택된 답변

Ingrid
Ingrid 2015년 6월 15일
and
data(end-1,:)= 0;
is not the same as
data(end-1,:)= [];
only the latter removes the penultimate line to make it a 2x4 matrix, the first statement will put it to zero which will not show since all your values are zero in this case
and as Henric said, uitable2 does not exist, you need to use the handle to uitable1
  댓글 수: 2
Ingrid
Ingrid 2015년 6월 15일
You could also think about adding an edit text field where you can type in the row number that you will delete sine it does not always make sense to delete the last (or in the case you code, the penultimate) row
Paul Nanfah
Paul Nanfah 2015년 6월 15일
Thank you for the answer and for the suggestion too ! to open a new question was useless indeed, sorry for that

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by