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: find
Replies: 2   Last Post: Mar 3, 2013 7:48 PM

Advanced Search

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

Posts: 3,893
Registered: 12/7/04
Re: find
Posted: Mar 3, 2013 7:48 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On Monday, March 4, 2013 1:28:25 PM UTC+13, Nasser M. Abbasi wrote:
> On 3/3/2013 5:10 PM, a h wrote:
>

> > Hey yall
>
> >
>
> > So i have vektor, and i want to find the position in the vektor where
>
> >the value is 50.2, but matlab keeps telling me
>
> >
>
> >>> find(x,50.2)
>
> > ??? Error using ==> find
>
> > Second argument must be a positive scalar integer.
>
> >
>
> >
>
> > what to do??,
>
> >
>
>
>
> http://www.mathworks.com/help/matlab/ref/find.html
>
>
>
> "
>
> ind = find(X, k) or ind = find(X, k, 'first') returns at most the first
>
> k indices corresponding to the nonzero entries of X. k must be
>
> a positive integer, but it can be of any numeric data type."
>
>
>
>
>
> may be you need find(x==50.2) instead


As Nasser points out, you've got the syntax wrong, but on top of that, since you're using floating point numbers, you should use:
find(abs(x-50.2)<tol)
where tol is a tolerance, say 1e-6.
The reason is explained here:
http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F


Date Subject Author
3/3/13
Read Re: find
Nasser Abbasi
3/3/13
Read Re: find
Derek Goring

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.