Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Finding position in array
Replies: 10   Last Post: Jun 6, 2014 6:42 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
dpb

Posts: 8,231
Registered: 6/7/07
Re: Finding position in array
Posted: Jun 6, 2014 2:50 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 6/6/2014 1:11 PM, Bruno Luong wrote:
> dpb <none@non.net> wrote in message <lmsth7$ekd$1@speranza.aioe.org>...
>> On 6/6/2014 12:03 PM, Bruno Luong wrote:
>> >>
>> >> Yet another approach somewhat akin to Bruno's...
>> >>

>> >> >> interp1(a,1:length(a),x,'nearest')
>> >> ans =
>> >> 3

>> >
>> > Not completely equivalent, INTERP1 will has the resulting index

>> jumps by
>> > 1 unit when passing the middle point of the EDGES, whereas HISTC jumps
>> > right at the EDGES.

>>
>> Didn't say it was equivalent; only that it is "_somewhat_ akin to"...

>
> You should point out the difference, otherwise it can be missleading for
> OP.


What's misleading? I pointed out it was an alternative; he didn't
specify precisely what solution he wished...you didn't give any
explanation of your solution, either or how it differs from FIND.

Seems pretty picky nitting to me...

>> > INTERP1 and HISTC methods can deal with x as vector (not FIND()).
>>
>> But FIND() returns the specific preceding/following index value
>> depending on the usage if that's significant. The vector of lookup
>> values is easily dealt with via ARRAYFUN

>
> IMO ARRAYFUN is a poor choice when speed is important for large array of
> x. I often prefer for-loop compared to ARRAYFUN.


Whatever...again OP didn't say anything about array size(s) from which
to judge whether speed would be an issue or not...

--





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.