Can i delete part of a cell array based on a condition?
1 view (last 30 days)
Show older comments
Damien Williams
on 8 May 2019
Commented: Damien Williams
on 8 May 2019
if i have a cell array such as {'CGU'} {'UUU'} {'UAG'} {'GGU'} can i
identify if there is a member of {'UAA','UAG','UGA'} and delete the
remaining elements? eg, leaving {'CGU'} {'UUU'} once {'UAG'} is identified.
0 Comments
Accepted Answer
James Tursa
on 8 May 2019
Edited: James Tursa
on 8 May 2019
E.g.,
>> C = {'CGU','UUU','UAG','GGU'}
C =
1×4 cell array
{'CGU'} {'UUU'} {'UAG'} {'GGU'}
>> X = {'UAA','UAG','UGA'}
X =
1×3 cell array
{'UAA'} {'UAG'} {'UGA'}
>> f = find(ismember(C,X),1)
f =
3
>> C(f+1:end) = []
C =
1×3 cell array
{'CGU'} {'UUU'} {'UAG'}
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!