How to remove the last row in a matrix?

조회 수: 41 (최근 30일)
Ashish
Ashish 2014년 2월 13일
댓글: Ashish 2014년 2월 14일
Using GUIDE, I have made a table. In that, there is a "pushbutton" if the user wants to remove the rows.
I am not able to remove
% --- Executes on button press in remove_button.
function remove_button_Callback(hObject, eventdata, handles)
% hObject handle to remove_button (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% By default the remove button will only remove the last row in the
% table
dat = get(handles.eptable,'Data');
sz = size(dat);
dat(sz(1),1)=[];
I get the following error:
??? A null assignment can have only one non-colon index.
What is the solution of removing the last row?

채택된 답변

Walter Roberson
Walter Roberson 2014년 2월 13일
dat(sz(1),:) = [];
or
dat(end,:) = [];
  댓글 수: 5
Jos (10584)
Jos (10584) 2014년 2월 13일
dat = dat(max(1,size(dat,1)-1),:)
Ashish
Ashish 2014년 2월 14일
Thanks Walter and Jos for the feedback!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by