Remove specific cells in a cell array

I have a field_list that contains a large number of cells I will show a simple example :
fields_list = {'mode','time','date','Nav','state',...};
and I have another list for the fields I want to remove, for the same example:
remove_list = {'mode','date','Nav',,...};
is there a way to remove the 'remove_list' from the field_list' ?
Taking into account that the the fields_list and the remove_list are much bigger than this.

 採用された回答

Voss
Voss 2023 年 2 月 15 日

1 投票

fields_list = {'mode','time','date','Nav','state'};
remove_list = {'mode','date','Nav'};
fields_list(ismember(fields_list,remove_list)) = []
fields_list = 1×2 cell array
{'time'} {'state'}

2 件のコメント

Khoder Makkawi
Khoder Makkawi 2023 年 2 月 16 日
Thank you
Voss
Voss 2023 年 2 月 16 日
You're welcome!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

製品

リリース

R2022a

質問済み:

2023 年 2 月 15 日

コメント済み:

2023 年 2 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by