[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Wrong indices returned using Lookup for cells containing strings
From: |
rcharan51 |
Subject: |
Re: Wrong indices returned using Lookup for cells containing strings |
Date: |
Tue, 20 Oct 2015 21:51:52 -0700 (PDT) |
So sorting seems to solve the problem. Thank you guys.
Best Regards,
Raghu Charan A,
B. Tech (Hons) Civil Engineering (class of 2015),
School of Infrastructure,IIT Bhubaneswar, India.
Email: address@hidden, address@hidden
Mobile No: +91 8860567691, +91 7205733924
On Tue, Oct 20, 2015 at 6:51 PM, NJank [via Octave] <
address@hidden> wrote:
> On Tue, Oct 20, 2015 at 8:42 AM, Olaf Till <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4673021&i=0>> wrote:
>
>> On Tue, Oct 20, 2015 at 08:25:21AM -0400, Nicholas Jankowski wrote:
>> > On Tue, Oct 20, 2015 at 8:06 AM, Olaf Till <[hidden email]
>> <http:///user/SendEmail.jtp?type=node&node=4673021&i=1>> wrote:
>> >
>> > > On Tue, Oct 20, 2015 at 02:37:15AM -0700, rcharan51 wrote:
>> > > > i have two cell arrays(strings) of size 20X1 and 3X1. when i tried
>> to
>> > > lookup
>> > > > larger cell array in the shorter one the indices returned are not
>> > > correct.
>> > > > My guess is that since the cells in the short array are not sorted
>> in any
>> > > > particular order, wrong indices are returned. Am i right? if so
>> what is
>> > > work
>> > > > around for this?
>> > > > any help is much appreciated. Thanks.
>> > > >
>> > > > >> b=geo_ch(1:20, 1)
>> > > > b =
>> > > > {
>> > > > [1,1] = GEN
>> > > > [2,1] = GEN
>> > > > [3,1] = GEN
>> > > > [4,1] = GEN
>> > > > [5,1] = GEN
>> > > > [6,1] = GEN
>> > > > [7,1] = GEN
>> > > > [8,1] = GEN
>> > > > [9,1] = GEN
>> > > > [10,1] = GEN
>> > > > [11,1] = GEN
>> > > > [12,1] = GEN
>> > > > [13,1] = GEN
>> > > > [14,1] = GEN
>> > > > [15,1] = GEN
>> > > > [16,1] = GEN
>> > > > [17,1] = WEAK
>> > > > [18,1] = WEAK
>> > > > [19,1] = WEAK
>> > > > [20,1] = WEAK
>> > > > }
>> > > > >> a=trop1mix(4:6,1)
>> > > > a =
>> > > > {
>> > > > [1,1] = GEN
>> > > > [2,1] = WEAK
>> > > > [3,1] = MIX
>> > > > }
>> > > > >> id=lookup(a,b)
>> > > > id =
>> > > >
>> > > > 1
>> > > > 1
>> > > > 1
>> > > > 1
>> > > > 1
>> > > > 1
>> > > > 1
>> > > > 1
>> > > > 1
>> > > > 1
>> > > > 1
>> > > > 1
>> > > > 1
>> > > > 1
>> > > > 1
>> > > > 1
>> > > > 3
>> > > > 3
>> > > > 3
>> > > > 3
>> > >
>> > > But the above seems correct to me ... Olaf
>> > >
>> > >
>> > I assume he's expecting 1's followed by 2's. I've never used lookup for
>> > non-numerical arrays, but I know it generally expects a to be monotonic.
>> > the help says for strings "lookup is performed using lexicographical
>> > comparison". I notice his a is 'lexocographically' monotonic but b is
>> > not. is that the source of his confusion? Olaf, can you explain why
>> the
>> > output of 3 should be expected, rather than the 2 he was expecting?
>>
>> No, I can't. I just mixed it up in my head. That's the second time
>> today, seems it's not my day ... And you are surely right with the
>> table having to be monotonic. So 'a = sort (a)' should solve the
>> problem ...
>>
>>
> Nope. lookup(sort(a),b) produces the same output.
>
> Also, I was curious to see if Matlab produced the same results. turns out
> it errors when presented with cell arrays.
>
> >> id = lookup(a,b)
> Undefined function 'lookup' for input arguments of type 'cell'.
>
>
> _______________________________________________
> Help-octave mailing list
> [hidden email] <http:///user/SendEmail.jtp?type=node&node=4673021&i=2>
> https://lists.gnu.org/mailman/listinfo/help-octave
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://octave.1599824.n4.nabble.com/Wrong-indices-returned-using-Lookup-for-cells-containing-strings-tp4673014p4673021.html
> To start a new topic under Octave - General, email
> address@hidden
> To unsubscribe from Wrong indices returned using Lookup for cells
> containing strings, click here
> <http://octave.1599824.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4673014&code=c3JhMTBAaWl0YmJzLmFjLmlufDQ2NzMwMTR8MTU5MDQyODc2Mw==>
> .
> NAML
> <http://octave.1599824.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
------------------------------
*Disclaimer: *This email and any files transmitted with it are confidential
and intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify the
system manager. This message contains confidential information and is
intended only for the individual named. If you are not the named addressee
you should not disseminate, distribute or copy this e-mail. Please notify
the sender immediately by e-mail if you have received this e-mail by
mistake and delete this e-mail from your system. If you are not the
intended recipient you are notified that disclosing, copying, distributing
or taking any action in reliance on the contents of this information is
strictly prohibited.
--
View this message in context:
http://octave.1599824.n4.nabble.com/Wrong-indices-returned-using-Lookup-for-cells-containing-strings-tp4673014p4673026.html
Sent from the Octave - General mailing list archive at Nabble.com.
- Wrong indices returned using Lookup for cells containing strings, rcharan51, 2015/10/20
- Re: Wrong indices returned using Lookup for cells containing strings, Olaf Till, 2015/10/20
- Re: Wrong indices returned using Lookup for cells containing strings, Nicholas Jankowski, 2015/10/20
- Re: Wrong indices returned using Lookup for cells containing strings, Olaf Till, 2015/10/20
- Re: Wrong indices returned using Lookup for cells containing strings, Nicholas Jankowski, 2015/10/20
- Re: Wrong indices returned using Lookup for cells containing strings, Nicholas Jankowski, 2015/10/20
- Re: Wrong indices returned using Lookup for cells containing strings,
rcharan51 <=
- Re: Wrong indices returned using Lookup for cells containing strings, Francesco PotortÃ¬, 2015/10/21
- Re: Wrong indices returned using Lookup for cells containing strings, Nicholas Jankowski, 2015/10/21
- Re: Wrong indices returned using Lookup for cells containing strings, Mike Miller, 2015/10/21
- Re: Wrong indices returned using Lookup for cells containing strings, Olaf Till, 2015/10/21
- Re: Wrong indices returned using Lookup for cells containing strings, Francesco PotortÃ¬, 2015/10/22