ismember() returning without unique indexing

조회 수: 9 (최근 30일)
JC
JC 2011년 5월 18일
I want to get a result from ismember function such that
a =[{'aa'};{'bb'};{'cc'};{'dd'};{'ee'}];
b = [{'bb'};{'bb'};{'dd'};{'dd'};{'dd'};{'dd'}];
idx = find(ismember(a,b) == 1);
then idx = [2 4];
however, I want to get the results like idx = [2 2 4 4 4 4];
so, the frequency of cell array in b is conserved.
Would please somebody help me?
Thanks.
justin

채택된 답변

Oleg Komarov
Oleg Komarov 2011년 5월 18일
[tf,loc] = ismember(b,a);
loc.' =
2 2 4 4 4 4
  댓글 수: 1
Jan
Jan 2011년 5월 18일
@JC: You find this behaviour explained in the help text. It is worth to read.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by