help-octave
[Top][All Lists]
Advanced

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

Re: A point in a vector?


From: martin_helm
Subject: Re: A point in a vector?
Date: Wed, 30 Sep 2009 14:22:59 -0700 (PDT)



Corrado wrote:
> 
> Dear list,
> 
> I have a strange requirement .... I have a vector, for example 
> 
> v=[0,0,0,0,1,2,4,6,8,8,8,8]. I have a value,for example x=4.8. 
> 
> I would like to understand in which sub interval of v is x. 
> 
> In this case, v would be in the sub interval [4,6] that is in the
> subinterval 
> starting from element j=7 to the element j+1=8.
> 
> Can we do that with an octave command?
> 
> Regards
> -- 
> Corrado Topi
> 
> Global Climate Change & Biodiversity Indicators
> Area 18,Department of Biology
> University of York, York, YO10 5YW, UK
> Phone: + 44 (0) 1904 328645, E-mail: address@hidden
> 
> 
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
> 
> 

You can use the lookup function

v=[0,0,0,0,1,2,4,6,8,8,8,8];
lookup(v, 4.3)

lookup assumes an ordered vector and performs very fast O(log(n))

- mh


-- 
View this message in context: 
http://www.nabble.com/A-point-in-a-vector--tp25688207p25689277.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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