delelte certain string data from cell

3 vues (au cours des 30 derniers jours)
Muhammad
Muhammad le 29 Mai 2021
Modifié(e) : Jonas le 30 Mai 2021
i want to delete Australia from this data using code
name= names (~any(cellfun('Australia',names),1:)
but i gives error so tell me an other way to del it

Réponse acceptée

Star Strider
Star Strider le 29 Mai 2021
The ismember function is usually reliable in these situations —
C = {'abc';'def';'ghi';'ghi';'ghi';'jkl';'mno';'pqr'}
C = 8×1 cell array
{'abc'} {'def'} {'ghi'} {'ghi'} {'ghi'} {'jkl'} {'mno'} {'pqr'}
TF = ismember(C,'ghi')
TF = 8×1 logical array
0 0 1 1 1 0 0 0
Cnew = C(~TF,:)
Cnew = 5×1 cell array
{'abc'} {'def'} {'jkl'} {'mno'} {'pqr'}
.

Plus de réponses (1)

Jonas
Jonas le 29 Mai 2021
Modifié(e) : Jonas le 30 Mai 2021
use
names(ismember(names(:,1),'Australia'),:)=[];

Catégories

En savoir plus sur Structures dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by