removing an entire row

1 view (last 30 days)
Daneisha Blair
Daneisha Blair on 31 Aug 2021
Commented: Daneisha Blair on 31 Aug 2021
I have array where in column 3 contains names, see attached image. I want to remove the row that is not duplicated in other words has different name, for example grace in the image. The logic approach I want to use to is: if all rows in column 3 are not equal to "fred", then remove that row.
I've tried this approach below, but no success.
if isempty(a)==1
Note: x="fred" and test is the array
Thank for your help.

Accepted Answer

Sean de Wolski
Sean de Wolski on 31 Aug 2021
grace = s(s(:,3)~="fred",:)
  1 Comment
Daneisha Blair
Daneisha Blair on 31 Aug 2021
Thank you Sean, this located the row that contains grace. Now, how can I remove the row (grace) from the s array?

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