help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Wrong indices returned using Lookup for cells containing strings


From: Francesco Potortì
Subject: Re: Wrong indices returned using Lookup for cells containing strings
Date: Wed, 21 Oct 2015 14:34:23 +0200

>> Yes.  When doing lookup(TABLE, Y), TABLE must be sorted.  This is not
>> clear from the docs, I filed a bug report.
>>
>
>Hmm, then why did I get the same output for
>
>>> lookup(a,b)
>
>And
>
>>> lookup(sort(a),b)

Chance.  I assume that the lookup algorithm is not defined for unsorted
input, and does not check for a sorted table for efficiency reasons.
Look at this:

>> lookup([1 2 3 4 5 6 7 8 9], [3 5])
ans =
   3   5
>> lookup([1 2 6 7 5 8 9 3 4], [3 5])
ans =
   2   9

>> lookup({"1" "2" "3" "4" "5" "6" "7" "8" "9"}, {"3" "5"})
ans =
   3   5
>> lookup({"1" "2" "6" "7" "5" "8" "9" "3" "4"}, {"3" "5"})
ans =
   2   9
>> 

-- 
Francesco Potortì (ricercatore)        Voice:  +39.050.621.3058
ISTI - Area della ricerca CNR          Mobile: +39.348.8283.107
via G. Moruzzi 1, I-56124 Pisa         Skype:  wnlabisti
(entrance 20, 1st floor, room C71)     Web:    http://fly.isti.cnr.it




reply via email to

[Prev in Thread] Current Thread [Next in Thread]