Filter löschen
Filter löschen

How to remove the last row in a matrix?

33 Ansichten (letzte 30 Tage)
Ashish
Ashish am 13 Feb. 2014
Kommentiert: Ashish am 14 Feb. 2014
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?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 13 Feb. 2014
dat(sz(1),:) = [];
or
dat(end,:) = [];
  5 Kommentare
Jos (10584)
Jos (10584) am 13 Feb. 2014
dat = dat(max(1,size(dat,1)-1),:)
Ashish
Ashish am 14 Feb. 2014
Thanks Walter and Jos for the feedback!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by