MATLAB Answers

How can I delete data from a variable in a table?

9 views (last 30 days)
How can I delete data from a variable in a table: For example,
I want to delete all rows that has 'Not Collected' under SampledDate.
  4 Comments
Waleed Nowayti
Waleed Nowayti on 3 Aug 2021
This is what I did Rik, and it is working for me!
W = table2cell(TEST);
IndexW = find(contains(W(:,7), 'Not Collected'));
% I used (:,7) to locate the column instead of using its name!
TEST(IndexW,:)=[];

Sign in to comment.

Accepted Answer

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 24 Jul 2021
In fact, it is not viable to delete only rows as dpb stated.
Otherwise, if you'd like to remove all elements of specific rows, that can be done relatively easy, e.g.:
TAB(TAB.SampledDate=='Not Collected', :)=[];
  8 Comments
Waleed Nowayti
Waleed Nowayti on 3 Aug 2021
That is amazing! I see the difference and your example is just straight to the point. Thank you so much for explaining!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by