Emulate Matlab's ismember function in Scilab

Sébastien Bihorel pomchip at free.fr
Sun Nov 8 12:29:01 CET 2009


Dear Scilab users,

Is there an easy method to emulate the Matlab ismember function to match
numerical vectors to one another? I've  tried several things with intersect
but it does not seem to give consistent results.

Here is a section of the Matlab help about ismember:
[tf, loc] = ismember(A, S, ...) returns an array loc containing the *highest
*index in S for each element in A that is a member of S.


Here is an example of Scilab code that I tried
a = [5 3 1 7 2 9 2 6 4 1 3 6 8 0 1 4];
b=1:5;
[v,ka,kb]=intersect(a,b,'c');

Surprisingly, ka is a mix of low, middle or high indexes... There must a
logic behind that, but I do not see the pattern.

I am looking to extract only the highest indexes. Any help would be
appreciated.

Sebastien
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20091108/95246783/attachment.htm>


More information about the users mailing list