フィルターのクリア

Compare elements of two cell vectors

1 回表示 (過去 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 Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by