How to delete some specific rows in a cell matrix?

Lets say i have a cell matrix of A = {'youth' 'cool' 'poor' ;'youth' 'notcool' 'poor' ;'old' 'notcool' 'rich'}; i want to delete the rows which contains 'youth' , so that my remaining answer will be only A={'old' 'notcool' 'rich'}

Answers (1)

r = any(cellfun(@(x)isequal(x,'youth'),A),2); % Rows that contain 'youth'
A(r,:) = []; % Delete those rows

This question is closed.

Asked:

on 28 Feb 2017

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!