필터 지우기
필터 지우기

Difference of cell arrays containing strings

조회 수: 2 (최근 30일)
Ralf
Ralf 2015년 2월 12일
댓글: Stephen23 2015년 2월 12일
Hello everybody,
I try to calculate the difference of two cell arrays containing strings. I want to identify the unique strings which are only present in one of the cell arrays. Here is an example:
Cell1 = {'Joe', 'Ralph', 'Sandra'};
Cell2 = {'Joe', 'Sandra'};
I now want to calculate Cell3 containing the "difference" of these two arrays, that means Cell3 should be equal to {'Ralph'}. For simplicity it could be assumed that all components of Cell2 are also components of Cell1. I want to identify the extra components in Cell1.
Any ideas? Thank you very much!

채택된 답변

Stephen23
Stephen23 2015년 2월 12일
편집: Stephen23 2015년 2월 12일
Use setdiff.
From the documentation: C = setdiff(A,B) returns the data in A that is not in B.
  댓글 수: 2
Ralf
Ralf 2015년 2월 12일
That was simple! I couldn't find this on my own.
Thank you very much!
Stephen23
Stephen23 2015년 2월 12일
Glad to help.
A tip for finding functions: learn to navigate the help contents (on the left-hand side of the page), you can discover lots of useful functions and advice here, and it is grouped intro useful concepts and categories. Ten minutes exploring this is time well spent.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by