How to remove a specific object from cell

1 回表示 (過去 30 日間)
Anil Rajajapantulu
Anil Rajajapantulu 2019 年 8 月 20 日
コメント済み: Anil Rajajapantulu 2019 年 8 月 22 日
I have a cell containing objects.
AllObjects = {obj1 , obj2 obj3 ....., obj10}
i want to remove obj3 from AllObjects cell.

採用された回答

Adam Danz
Adam Danz 2019 年 8 月 20 日
編集済み: Adam Danz 2019 年 8 月 21 日
Try this out
% identify the index of cell array "AllObjects" that contains "obj3"
idx = cellfun(@(x)isequal(x,obj3),AllObjects); %logical index
% Remove that index from cell array
AllObjects(idx) = [];
  1 件のコメント
Anil Rajajapantulu
Anil Rajajapantulu 2019 年 8 月 22 日
Thank you so much.

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

その他の回答 (1 件)

JIAYING WU
JIAYING WU 2019 年 8 月 20 日
AllObjects(3) = [ ];
  1 件のコメント
Adam Danz
Adam Danz 2019 年 8 月 20 日
...if you already know that obj3 is in position (3)

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

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by