Remove specific cells in a cell array

47 Ansichten (letzte 30 Tage)
Khoder Makkawi
Khoder Makkawi am 15 Feb. 2023
Kommentiert: Voss am 16 Feb. 2023
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.

Akzeptierte Antwort

Voss
Voss am 15 Feb. 2023
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 Kommentare
Khoder Makkawi
Khoder Makkawi am 16 Feb. 2023
Thank you
Voss
Voss am 16 Feb. 2023
You're welcome!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Types finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by