How to delete specific rows in a table based on a value?
106 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Carl Schneegaß
am 13 Dez. 2020
Beantwortet: Carl Schneegaß
am 16 Dez. 2020
Hi all,
I have a big table with 6 columns and would like to delete all rows where one column contains a specific value.
That's how the table looks like:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/459765/image.png)
I would like to delete all rows, where T.ISIN == 'DE0006205701'
May you please help me with this?
Thanks so much in advance!
5 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Image Analyst
am 13 Dez. 2020
Did you try ismember like I suggested above?
s = load('answers.mat')
T = s.T;
whos T % Show size.
% I would like to delete all rows, where T.ISIN == 'DE0006205701'
pattern = 'DE0006205701'
[ia, ib] = ismember(T.ISIN, {pattern});
fprintf('Found %d rows where ISIN = "%s". We will delete those.\n', sum(ia), pattern);
T(ia, :) = [];
whos T % Show size now.
1 Kommentar
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!