How to delete specific rows in a table based on a value?

24 views (last 30 days)
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:
I would like to delete all rows, where T.ISIN == 'DE0006205701'
May you please help me with this?
Thanks so much in advance!
  5 Comments
Carl Schneegaß
Carl Schneegaß on 13 Dec 2020
I had thought about something like
T = T(T.ISIN~='DE0006205701',:);
but it doesn't work for cell..

Sign in to comment.

Accepted Answer

Carl Schneegaß
Carl Schneegaß on 16 Dec 2020
I fortunately found the answer myself, it's
T = T(~contains(T.ISIN,'DE0006205701'),:);
Moroever, check out Image Analyst's solution, it works too!

More Answers (1)

Image Analyst
Image Analyst on 13 Dec 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 Comment
Carl Schneegaß
Carl Schneegaß on 13 Dec 2020
thanks a lot for your help, this definitely works!
I think maybe even easier might be
T = T(~contains(T.ISIN,'DE0006205701'),:);

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!