필터 지우기
필터 지우기

Compare elements of two cell vectors

조회 수: 4 (최근 30일)
Christian F.
Christian F. 2012년 5월 10일
Hi,
I have two cell vectors of different lengths, containing both numbers and numbers/characters.
Now, I want to delete all elements of vector A, which are not in vector B.
Best, Chris
  댓글 수: 1
per isakson
per isakson 2012년 5월 10일
Did you search the FEX (File Exchange)? Did you experiment with the function, ismember?

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

채택된 답변

Christian F.
Christian F. 2012년 5월 10일
I found a solution.
First I converted all elements of both cell arrays to strings with this code I found:
numIndex = cellfun('isclass', B, 'double');
tmpStr = sprintf('%g;', B{numIndex});
B(numIndex) = dataread('string', tmpStr, '%s', 'delimiter', ';');
Then I compared the arrays with
ismember(A,B)
Thanks all anyway.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by