ismember error

2 ビュー (過去 30 日間)
joseph Frank
joseph Frank 2011 年 8 月 16 日
Hi,
x0=find(ismember(A,B)==1) is giving me error ??? Error using ==> cell.ismember at 28 Input must be cell arrays of strings.
A is a cell array that has the following format: '580135' '803111' '803111' '803111' '373298' '373298'
Bis a 1x1 cell wit the following format 377298;
I don't know why A has '' and B doesn't ,which could be the source of error.

回答 (2 件)

Paulo Silva
Paulo Silva 2011 年 8 月 16 日
It works just fine in this example, you also don't need the ==1 in the find argument.
A={'580135' '803111' '803111' '803111' '377298' '373298' '373298'}
B={'377298'}
find(ismember(A,B))

Walter Roberson
Walter Roberson 2011 年 8 月 16 日
Please clarify whether the content of B{1} is numeric or a string. It would need to be a string for this purpose.
Is this an example, with more values of B to be added later, or are you looking to find B within A? If you are looking to find B within A then you would use ismember(B,A)
The == 1 is redundant with ismember() as it is all 0 or 1 anyhow. find(ismember(A,B))
  2 件のコメント
joseph Frank
joseph Frank 2011 年 8 月 16 日
B sometimes is a number and sometimes is a string, find(ismember(A,B))is what i need but it gives the above mentioned error
Jan
Jan 2011 年 8 月 16 日
@Joseph: Then ISMEMBER is *not* what you need. It cannot compare strings with numbers. What do you expect as result of such a comparison?

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

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by