constructing sequence of ismember
Show older comments
Hi all,
I have the vector A=
‘l1’
‘l2’
‘Kl9’
‘E9’
…
In my case, A contains hundreds of different elements (‘l1’,‘l2’,…). I want to produce a series of
lopp(ismember(c,{'x' })) where x stands for each element of A So I want to have
B=[ lopp(ismember(c,{'l1' })) lopp(ismember(c,{'l2' })) lopp(ismember(c,{'KI9' })) lopp(ismember(c),{'E9' }))…]
Is there any code that will enable me to construct B automatically
thanks
Answers (1)
Walter Roberson
on 23 May 2012
[tf, idx] = ismember(c, A);
B = lopp(idx(tf))
9 Comments
antonet
on 23 May 2012
antonet
on 23 May 2012
Walter Roberson
on 23 May 2012
I will cross-check later when I'm at my desk.
antonet
on 23 May 2012
Walter Roberson
on 23 May 2012
Try
[tf, idx] = ismember(A,c);
B = lopp(idx(tf));
antonet
on 23 May 2012
antonet
on 23 May 2012
Walter Roberson
on 23 May 2012
There are repeats in c ? Hmmm, I'll have to think about this a bit more.
antonet
on 24 May 2012
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!