Search All of the Math Forum:

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

Topic: Indexing
Replies: 4   Last Post: Mar 7, 2013 2:24 PM

 Messages: [ Previous | Next ]
 Eric Posts: 5 Registered: 9/7/12
Re: Indexing
Posted: Mar 7, 2013 1:56 PM

dpb <none@non.net> wrote in message <kh80br\$98u\$1@speranza.aioe.org>...
> On 3/5/2013 9:16 PM, Eric wrote:
> > Hi,
> >
> > I know I should be able to figure this out based on previous posts, but
> > I still cannot find the correct solution. Within matrix A (nx1 matrix),
> > I want to find the first instance that a value BW is 10 units less than
> > BW--I'll call this value DROP. It is not a min or max value. I am just
> > trying to index points on a force waveform so I can eventually integrate
> > the area between points.
> >
> > Specifically:
> > BW= 650; DROP = BW-10;
> > [event1,ind1] = A(DROP,1);
> >
> > Using this, I get an error 'Indexing cannot yield multiple results'.
> > I tried using find but all the values will be positive numbers.

> ...
>
> ix=find(A==DROP,1); % the first index
> A(ix) % the value at that index
>
> NB: If A is floating point and not integer-value, the problem of exact
> comparisons for floating point values may rear its head...the values
> you've shown are integers well withing DP resolution so will be stored
> exactly, but that's not necessarily so in general of course.
>
> --

Thanks for this. You were correct that the problem of exact comparisons for floating point values became an issue because all numbers in A were non-integers. I rounded the values using floor since I do not need to be accurate to a tenths decimal place with the data I am working with.

Date Subject Author
3/5/13 Eric
3/5/13 Derek Goring
3/6/13 dpb
3/7/13 Eric
3/7/13 dpb