delelte certain string data from cell

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

 採用された回答

Star Strider
Star Strider 2021 年 5 月 29 日

0 投票

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'}
.

その他の回答 (1 件)

Jonas
Jonas 2021 年 5 月 29 日
編集済み: Jonas 2021 年 5 月 30 日

0 投票

use
names(ismember(names(:,1),'Australia'),:)=[];

カテゴリ

ヘルプ センター および File ExchangeStructures についてさらに検索

質問済み:

2021 年 5 月 29 日

編集済み:

2021 年 5 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by