http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724
MATLAB Central Newsreader  'find' returns noninteger indices (potential bug?)
Feed for thread: 'find' returns noninteger indices (potential bug?)
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Tue, 30 Dec 2008 13:38:01 +0000
'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619267
Tamar Friedlander
After extensive use in a simiulation, it occurs once in a while that 'find' returns noninteger indices! (happened in Matlab 7.5.0)<br>
<br>
Typing the index in a long format I received something like: 61,143.000001. Trying to round the indices didn't help either.<br>
<br>
This happens at different timings and seems unrelated to the simulation code, and is unreproducible if the very same code line is retyped.<br>
<br>
Is it a bug or could I be misusing 'find'?<br>
Does anyone know how to avoid it (except for rewriting the code which will not use 'find')?

Tue, 30 Dec 2008 14:53:32 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619277
Rune Allnor
On 30 Des, 14:38, "Tamar Friedlander" <tammy_in_the_an...@yahoo.com><br>
wrote:<br>
> After extensive use in a simiulation, it occurs once in a while that 'find' returns noninteger indices! (happened in Matlab 7.5.0)<br>
<br>
Do you have an example where this happens?<br>
<br>
> Typing the index in a long format I received something like: 61,143.000001. Trying to round the indices didn't help either.<br>
><br>
> This happens at different timings and seems unrelated to the simulation code, and is unreproducible if the very same code line is retyped.<br>
><br>
> Is it a bug or could I be misusing 'find'?<br>
> Does anyone know how to avoid it (except for rewriting the code which will not use 'find')?<br>
<br>
This is likely a consequence of matlab not being a typed language.<br>
Everything is represented as doubleprecision floating point numbers.<br>
Integers are represented as floats to within numerical precision.<br>
In the example above it seems that the deviation from the integer<br>
value happens at the significant digit near the floating point<br>
accuracy.<br>
<br>
Rune

Tue, 30 Dec 2008 15:38:52 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619285
Loren Shure
In article <gjd87p$q3m$1@fred.mathworks.com>, <br>
tammy_in_the_andes@yahoo.com says...<br>
> After extensive use in a simiulation, it occurs once in a while that 'find' returns noninteger indices! (happened in Matlab 7.5.0)<br>
> <br>
> Typing the index in a long format I received something like: 61,143.000001. Trying to round the indices didn't help either.<br>
> <br>
> This happens at different timings and seems unrelated to the simulation code, and is unreproducible if the very same code line is retyped.<br>
> <br>
> Is it a bug or could I be misusing 'find'?<br>
> Does anyone know how to avoid it (except for rewriting the code which will not use 'find')?<br>
> <br>
> <br>
> <br>
<br>
Are you sure you are not doing some arithmetic after the call to find <br>
that causes this? Perhaps you can narrow down code to a reproducible <br>
example and post that code.<br>
<br>
 <br>
Loren<br>
<a href="http://blogs.mathworks.com/loren">http://blogs.mathworks.com/loren</a>

Tue, 30 Dec 2008 15:53:04 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619290
Steve Eddins
Rune Allnor wrote:<br>
> On 30 Des, 14:38, "Tamar Friedlander" <tammy_in_the_an...@yahoo.com><br>
> wrote:<br>
>> After extensive use in a simiulation, it occurs once in a while that 'find' returns noninteger indices! (happened in Matlab 7.5.0)<br>
> <br>
> Do you have an example where this happens?<br>
> <br>
>> Typing the index in a long format I received something like: 61,143.000001. Trying to round the indices didn't help either.<br>
>><br>
>> This happens at different timings and seems unrelated to the simulation code, and is unreproducible if the very same code line is retyped.<br>
>><br>
>> Is it a bug or could I be misusing 'find'?<br>
>> Does anyone know how to avoid it (except for rewriting the code which will not use 'find')?<br>
> <br>
> This is likely a consequence of matlab not being a typed language.<br>
<br>
MATLAB is a dynamically typed language.<br>
<br>
> Everything is represented as doubleprecision floating point numbers.<br>
<br>
That hasn't been true for more than ten years.<br>
<br>
> Integers are represented as floats to within numerical precision.<br>
<br>
Although that's no longer always true, it is accurate with respect to <br>
the output of find, which does return doubleprecision floats. However, <br>
there is no floatingpoint arithmetic going on in the internal code. If <br>
find really is returning a noninteger value, it's a plain ol' bug having <br>
nothing whatever to do with types, floatingpoint, etc.<br>
<br>
However, I do not usually start out by assuming a trouble report is <br>
really a bug, especially in this case, where I haven't yet seen a line <br>
of code. So I don't really know how find has been called, and if <br>
anything else might have operated on the output from find between the <br>
call and when the output was displayed. For all we know from the <br>
information posted so far, the root cause could be a userwritten <br>
MEXfile that has corrupted MATLAB's internal data structures. Or maybe <br>
earlier code has actually assigned a value to a variable called "find", <br>
so that later code is actually indexing into that variable instead of <br>
calling the function "find". Either of those explanations strike me as <br>
more likely than an actual bug in find.<br>
<br>
To the original poster, Tamar, I suggest setting a conditional <br>
breakpoint on the line containing the call to find, so that the debugger <br>
will stop there if any of the output values are nonempty. You might be <br>
able to find a reproducible test case that way. Oh, and doublecheck <br>
that you aren't using "find" as a variable name somewhere.<br>
<br>
<br>
Steve Eddins<br>
<a href="http://blogs.mathworks.com/steve/">http://blogs.mathworks.com/steve/</a>

Tue, 30 Dec 2008 15:59:02 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619291
Tamar Friedlander
My code (a little simplified) is this:<br>
<br>
dilution = rand (size(S)) > ((length(S)  N0) / length(S));<br>
diluted_S = S (find(dilution));<br>
S = diluted_S; <br>
<br>
There is no arithmetics involved. What I do is randomly choose some of the indices in 'S' and throw them away.<br>
<br>
Occassionally, this causes an error with error message about noninteger indices, while most of the time the code works properly.<br>
I checked, and to my surprise the indices returned by 'find' were indeed nonintegers!<br>
<br>
Any idea?<br>
<br>
Thanks,<br>
Tamar.<br>
<br>
Loren Shure <loren@mathworks.com> wrote in message <MPG.23c40a995544ece0989912@news.mathworks.com>...<br>
> In article <gjd87p$q3m$1@fred.mathworks.com>, <br>
> tammy_in_the_andes@yahoo.com says...<br>
> > After extensive use in a simiulation, it occurs once in a while that 'find' returns noninteger indices! (happened in Matlab 7.5.0)<br>
> > <br>
> > Typing the index in a long format I received something like: 61,143.000001. Trying to round the indices didn't help either.<br>
> > <br>
> > This happens at different timings and seems unrelated to the simulation code, and is unreproducible if the very same code line is retyped.<br>
> > <br>
> > Is it a bug or could I be misusing 'find'?<br>
> > Does anyone know how to avoid it (except for rewriting the code which will not use 'find')?<br>
> > <br>
> > <br>
> > <br>
> <br>
> Are you sure you are not doing some arithmetic after the call to find <br>
> that causes this? Perhaps you can narrow down code to a reproducible <br>
> example and post that code.<br>
> <br>
>  <br>
> Loren<br>
> <a href="http://blogs.mathworks.com/loren">http://blogs.mathworks.com/loren</a>

Tue, 30 Dec 2008 16:07:30 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619293
Rune Allnor
On 30 Des, 16:53, Steve Eddins <Steve.Edd...@mathworks.com> wrote:<br>
> Rune Allnor wrote:<br>
> > On 30 Des, 14:38, "Tamar Friedlander" <tammy_in_the_an...@yahoo.com><br>
> > wrote:<br>
> >> After extensive use in a simiulation, it occurs once in a while that '=<br>
find' returns noninteger indices! (happened in Matlab 7.5.0)<br>
...<br>
> > Integers are represented as floats to within numerical precision.<br>
><br>
> Although that's no longer always true, it is accurate with respect to<br>
> the output of find, which does return doubleprecision floats. =A0However=<br>
,<br>
> there is no floatingpoint arithmetic going on in the internal code.<br>
<br>
It doesn't need to be. All it takes to generate this type of error<br>
is a 'sufficiently large' roundoff error when representing the<br>
integer as a float. But those errors ought to be on the order of<br>
numerical precision, eps('double'), which is a bit smaller than<br>
1e12.<br>
<br>
> =A0If<br>
> find really is returning a noninteger value, it's a plain ol' bug having<br>
> nothing whatever to do with types, floatingpoint, etc.<br>
<br>
FIND has been around a bit too long for such a bug to have<br>
survived. But as you say, there could be any one of several<br>
reasons to cause the error  it would help to see some code.<br>
<br>
Rune

Tue, 30 Dec 2008 16:10:03 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619295
Tamar Friedlander
Hi,<br>
<br>
I am not using 'find' as a variable, and there is no MEXfile involved in my code either.<br>
<br>
Tamar.<br>
<br>
Steve Eddins <Steve.Eddins@mathworks.com> wrote in message <gjdg50$st3$1@fred.mathworks.com>...<br>
> Rune Allnor wrote:<br>
> > On 30 Des, 14:38, "Tamar Friedlander" <tammy_in_the_an...@yahoo.com><br>
> > wrote:<br>
> >> After extensive use in a simiulation, it occurs once in a while that 'find' returns noninteger indices! (happened in Matlab 7.5.0)<br>
> > <br>
> > Do you have an example where this happens?<br>
> > <br>
> >> Typing the index in a long format I received something like: 61,143.000001. Trying to round the indices didn't help either.<br>
> >><br>
> >> This happens at different timings and seems unrelated to the simulation code, and is unreproducible if the very same code line is retyped.<br>
> >><br>
> >> Is it a bug or could I be misusing 'find'?<br>
> >> Does anyone know how to avoid it (except for rewriting the code which will not use 'find')?<br>
> > <br>
> > This is likely a consequence of matlab not being a typed language.<br>
> <br>
> MATLAB is a dynamically typed language.<br>
> <br>
> > Everything is represented as doubleprecision floating point numbers.<br>
> <br>
> That hasn't been true for more than ten years.<br>
> <br>
> > Integers are represented as floats to within numerical precision.<br>
> <br>
> Although that's no longer always true, it is accurate with respect to <br>
> the output of find, which does return doubleprecision floats. However, <br>
> there is no floatingpoint arithmetic going on in the internal code. If <br>
> find really is returning a noninteger value, it's a plain ol' bug having <br>
> nothing whatever to do with types, floatingpoint, etc.<br>
> <br>
> However, I do not usually start out by assuming a trouble report is <br>
> really a bug, especially in this case, where I haven't yet seen a line <br>
> of code. So I don't really know how find has been called, and if <br>
> anything else might have operated on the output from find between the <br>
> call and when the output was displayed. For all we know from the <br>
> information posted so far, the root cause could be a userwritten <br>
> MEXfile that has corrupted MATLAB's internal data structures. Or maybe <br>
> earlier code has actually assigned a value to a variable called "find", <br>
> so that later code is actually indexing into that variable instead of <br>
> calling the function "find". Either of those explanations strike me as <br>
> more likely than an actual bug in find.<br>
> <br>
> To the original poster, Tamar, I suggest setting a conditional <br>
> breakpoint on the line containing the call to find, so that the debugger <br>
> will stop there if any of the output values are nonempty. You might be <br>
> able to find a reproducible test case that way. Oh, and doublecheck <br>
> that you aren't using "find" as a variable name somewhere.<br>
> <br>
> <br>
> Steve Eddins<br>
> <a href="http://blogs.mathworks.com/steve/">http://blogs.mathworks.com/steve/</a>

Tue, 30 Dec 2008 16:22:44 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619298
Steve Eddins
Tamar Friedlander wrote:<br>
> My code (a little simplified) is this:<br>
> <br>
> dilution = rand (size(S)) > ((length(S)  N0) / length(S));<br>
> diluted_S = S (find(dilution));<br>
> S = diluted_S; <br>
> <br>
> There is no arithmetics involved. What I do is randomly choose some of the indices in 'S' and throw them away.<br>
> <br>
> Occassionally, this causes an error with error message about noninteger indices, while most of the time the code works properly.<br>
> I checked, and to my surprise the indices returned by 'find' were indeed nonintegers!<br>
> <br>
> Any idea?<br>
> <br>
> Thanks,<br>
> Tamar.<br>
<br>
Use dbstop if error to stop when the error occurs to try to get a <br>
reproducible test case. When stopped in the debugger, try this at the <br>
command line:<br>
<br>
which all find<br>
<br>
If you get a reproducible test case, consider contacting tech support <br>
(www.mathworks.com/support/).<br>
<br>
You don't really need to the call to find in your code. You could do this:<br>
<br>
diluted_S = S(dilution);<br>
<br>
<br>
Steve Eddins<br>
<a href="http://blogs.mathworks.com/steve/">http://blogs.mathworks.com/steve/</a>

Tue, 30 Dec 2008 19:17:01 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619310
Tamar Friedlander
Thanks,<br>
Tamar.<br>
<br>
Steve Eddins <Steve.Eddins@mathworks.com> wrote in message <gjdhsk$g0g$1@fred.mathworks.com>...<br>
> Tamar Friedlander wrote:<br>
> > My code (a little simplified) is this:<br>
> > <br>
> > dilution = rand (size(S)) > ((length(S)  N0) / length(S));<br>
> > diluted_S = S (find(dilution));<br>
> > S = diluted_S; <br>
> > <br>
> > There is no arithmetics involved. What I do is randomly choose some of the indices in 'S' and throw them away.<br>
> > <br>
> > Occassionally, this causes an error with error message about noninteger indices, while most of the time the code works properly.<br>
> > I checked, and to my surprise the indices returned by 'find' were indeed nonintegers!<br>
> > <br>
> > Any idea?<br>
> > <br>
> > Thanks,<br>
> > Tamar.<br>
> <br>
> Use dbstop if error to stop when the error occurs to try to get a <br>
> reproducible test case. When stopped in the debugger, try this at the <br>
> command line:<br>
> <br>
> which all find<br>
> <br>
> If you get a reproducible test case, consider contacting tech support <br>
> (www.mathworks.com/support/).<br>
> <br>
> You don't really need to the call to find in your code. You could do this:<br>
> <br>
> diluted_S = S(dilution);<br>
> <br>
> <br>
> Steve Eddins<br>
> <a href="http://blogs.mathworks.com/steve/">http://blogs.mathworks.com/steve/</a>

Tue, 30 Dec 2008 22:51:03 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619333
Jos
"Tamar Friedlander" <tammy_in_the_andes@yahoo.com> wrote in message <gjdgg6$kme$1@fred.mathworks.com>...<br>
> My code (a little simplified) is this:<br>
> <br>
> dilution = rand (size(S)) > ((length(S)  N0) / length(S));<br>
> diluted_S = S (find(dilution));<br>
> S = diluted_S; <br>
> <br>
> There is no arithmetics involved. What I do is randomly choose some of the indices in 'S' and throw them away.<br>
> <br>
> Occassionally, this causes an error with error message about noninteger indices, while most of the time the code works properly.<br>
<br>
What was the error message?<br>
<br>
> I checked, and to my surprise the indices returned by 'find' were indeed nonintegers!<br>
<br>
How, precisely, did you check this in the above code? <br>
<br>
> <br>
> Any idea?<br>
> <br>
<br>
Not yet, you need to give more detailed information.<br>
<br>
Jos

Wed, 31 Dec 2008 12:53:01 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619374
Tamar Friedlander
I used the code lines I wrote above, and from time to time the program stopped with the error message:<br>
<br>
??? Subscript indices must either be real positive integers or logicals.<br>
<br>
pointing to the lines I wrote above.<br>
<br>
To enquire the source of this problem I substituted the indices into an intermediate variable, and then checked whether they were integers:<br>
<br>
dilution = rand (size(S)) > ((length(S)  N0) / length(S));<br>
AA = find(dilution));<br>
if sum (mod (AA, 1)) ~=0,<br>
error ('Noninteger index !!!')<br>
end; <br>
<br>
The program occassionally stopped with this error message, meaning that some of the indices were nonintegers.<br>
<br>
Then I typed in the command window:<br>
>>format long <br>
<br>
to present the full representation of these variables.<br>
>>[I,J]=find(mod(AA,1));<br>
>>AA(J)<br>
gave me numbers like: <br>
61143.000001 etc.<br>
<br>
I should also add that these line were in a loop that was repeated many times in the program. The problem seemed to occur at a random timing in the program (87th iteration, 52nd iteration and usually not at all).<br>
So I couldn't find any syntax error directly related to my code.<br>
Even after the program stopped with that error message, if I copied the problematic line into the command line, it was run properly and didn't produce the same error message.<br>
<br>
Tamar.<br>
<br>
"Jos " <#10584@fileexchange.com> wrote in message <gje8km$437$1@fred.mathworks.com>...<br>
> "Tamar Friedlander" <tammy_in_the_andes@yahoo.com> wrote in message <gjdgg6$kme$1@fred.mathworks.com>...<br>
> > My code (a little simplified) is this:<br>
> > <br>
> > dilution = rand (size(S)) > ((length(S)  N0) / length(S));<br>
> > diluted_S = S (find(dilution));<br>
> > S = diluted_S; <br>
> > <br>
> > There is no arithmetics involved. What I do is randomly choose some of the indices in 'S' and throw them away.<br>
> > <br>
> > Occassionally, this causes an error with error message about noninteger indices, while most of the time the code works properly.<br>
> <br>
> What was the error message?<br>
> <br>
> > I checked, and to my surprise the indices returned by 'find' were indeed nonintegers!<br>
> <br>
> How, precisely, did you check this in the above code? <br>
> <br>
> > <br>
> > Any idea?<br>
> > <br>
> <br>
> Not yet, you need to give more detailed information.<br>
> <br>
> Jos

Wed, 31 Dec 2008 17:53:02 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619419
Matt
"Tamar Friedlander" <tammy_in_the_andes@yahoo.com> wrote in message <gjfpvd$amc$1@fred.mathworks.com>...<br>
> I used the code lines I wrote above, and from time to time the program stopped with the error message:<br>
> <br>
> ??? Subscript indices must either be real positive integers or logicals.<br>
> <br>
> pointing to the lines I wrote above.<br>
> <br>
> To enquire the source of this problem I substituted the indices into an intermediate variable, and then checked whether they were integers:<br>
> <br>
> dilution = rand (size(S)) > ((length(S)  N0) / length(S));<br>
> AA = find(dilution));<br>
> if sum (mod (AA, 1)) ~=0,<br>
> error ('Noninteger index !!!')<br>
> end; <br>
> <br>
> The program occassionally stopped with this error message, meaning that some of the indices were nonintegers.<br>
<br>
<br>
Could you give us size(S), length(S), and N0 so we can try to reproduce this?

Thu, 01 Jan 2009 09:20:02 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619455
Tamar Friedlander
"Matt " <mjacobson.removethis@xorantech.com> wrote in message <gjgbhu$hqd$1@fred.mathworks.com>...<br>
> "Tamar Friedlander" <tammy_in_the_andes@yahoo.com> wrote in message <gjfpvd$amc$1@fred.mathworks.com>...<br>
> > I used the code lines I wrote above, and from time to time the program stopped with the error message:<br>
> > <br>
> > ??? Subscript indices must either be real positive integers or logicals.<br>
> > <br>
> > pointing to the lines I wrote above.<br>
> > <br>
> > To enquire the source of this problem I substituted the indices into an intermediate variable, and then checked whether they were integers:<br>
> > <br>
> > dilution = rand (size(S)) > ((length(S)  N0) / length(S));<br>
> > AA = find(dilution));<br>
> > if sum (mod (AA, 1)) ~=0,<br>
> > error ('Noninteger index !!!')<br>
> > end; <br>
> > <br>
> > The program occassionally stopped with this error message, meaning that some of the indices were nonintegers.<br>
> <br>
> <br>
> Could you give us size(S), length(S), and N0 so we can try to reproduce this?<br>
> <br>
<br>
Hi,<br>
N0=500000;<br>
S is a vector whose length changes randomly in the simulation and is approximately ~510000.<br>
The simulation randomly chooses indices from S and removes them, to make S of length ~500000 again.<br>
<br>
Tamar.

Thu, 01 Jan 2009 14:18:01 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619468
Matt
"Tamar Friedlander" <tammy_in_the_andes@yahoo.com> wrote in message <gji1s2$c1i$1@fred.mathworks.com>...<br>
> "Matt " <mjacobson.removethis@xorantech.com> wrote in message <gjgbhu$hqd$1@fred.mathworks.com>...<br>
> > "Tamar Friedlander" <tammy_in_the_andes@yahoo.com> wrote in message <gjfpvd$amc$1@fred.mathworks.com>...<br>
> > > I used the code lines I wrote above, and from time to time the program stopped with the error message:<br>
> > > <br>
> > > ??? Subscript indices must either be real positive integers or logicals.<br>
> > > <br>
> > > pointing to the lines I wrote above.<br>
> > > <br>
> > > To enquire the source of this problem I substituted the indices into an intermediate variable, and then checked whether they were integers:<br>
> > > <br>
> > > dilution = rand (size(S)) > ((length(S)  N0) / length(S));<br>
> > > AA = find(dilution));<br>
> > > if sum (mod (AA, 1)) ~=0,<br>
> > > error ('Noninteger index !!!')<br>
> > > end; <br>
> > > <br>
> > > The program occassionally stopped with this error message, meaning that some of the indices were nonintegers.<br>
> > <br>
> > <br>
> > Could you give us size(S), length(S), and N0 so we can try to reproduce this?<br>
> > <br>
> <br>
> Hi,<br>
> N0=500000;<br>
> S is a vector whose length changes randomly in the simulation and is approximately ~510000.<br>
> The simulation randomly chooses indices from S and removes them, to make S of length ~500000 again.<br>
> <br>
> Tamar. <br>
<br>
<br>
It may lead nowhere, but I would try doing<br>
<br>
>> feature accel off<br>
<br>
and rerun the code to see if it makes a difference. I've seen reports of the JIT accelerator causing weird problems...

Thu, 01 Jan 2009 16:33:01 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619477
Roger Stafford
"Tamar Friedlander" <tammy_in_the_andes@yahoo.com> wrote in message <gji1s2$c1i$1@fred.mathworks.com>...<br>
> N0=500000;<br>
> S is a vector whose length changes randomly in the simulation and is approximately ~510000.<br>
> The simulation randomly chooses indices from S and removes them, to make S of length ~500000 again.<br>
> <br>
> Tamar.<br>
<br>
I think you may have a valid basis for a complaint to Mathworks support, Tamar. Reduced to its essentials, you are claiming that when matlab's 'find' function is applied to a halfmillionlong logical vector which contains 98 percent true values, occasionally the returned indices are not all exact integers. It is very strange that this bug hasn't turned up long before this, so you shouldn't be surprised at a natural reluctance on Mathworks' part to immediately accept this.<br>
<br>
You also said in your original article, "Trying to round the indices didn't help either." I find that equally if not more remarkable. I have never known matlab's 'round' function to fail to return an integer. Are you very sure of this? If so, this would be another and quite different bug. Can you comment further on your statement. Two such unlikelysounding bugs occurring together might seem to imply there was something about your particular machine or its settings that was causing the errant performance.<br>
<br>
One further check I would recommend. You gave an example of a noninteger, 61143.000001, obtained using 'format long'. I wish you had done 'format hex' on the number so the individual bits could be deciphered from the hex digit display. The number is off from the exact integer 61143 down somewhere in the lower 18 bits out of a total of 53. I wonder what those errant bits are. I am also quite startled that 'round' is incapable of clearing them away if that is what you are saying.<br>
<br>
Roger Stafford

Thu, 01 Jan 2009 17:37:01 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619480
Tamar Friedlander
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gjir7t$ctl$1@fred.mathworks.com>...<br>
> "Tamar Friedlander" <tammy_in_the_andes@yahoo.com> wrote in message <gji1s2$c1i$1@fred.mathworks.com>...<br>
> > N0=500000;<br>
> > S is a vector whose length changes randomly in the simulation and is approximately ~510000.<br>
> > The simulation randomly chooses indices from S and removes them, to make S of length ~500000 again.<br>
> > <br>
> > Tamar.<br>
> <br>
> I think you may have a valid basis for a complaint to Mathworks support, Tamar. Reduced to its essentials, you are claiming that when matlab's 'find' function is applied to a halfmillionlong logical vector which contains 98 percent true values, occasionally the returned indices are not all exact integers. It is very strange that this bug hasn't turned up long before this, so you shouldn't be surprised at a natural reluctance on Mathworks' part to immediately accept this.<br>
> <br>
> You also said in your original article, "Trying to round the indices didn't help either." I find that equally if not more remarkable. I have never known matlab's 'round' function to fail to return an integer. Are you very sure of this? If so, this would be another and quite different bug. Can you comment further on your statement. Two such unlikelysounding bugs occurring together might seem to imply there was something about your particular machine or its settings that was causing the errant performance.<br>
> <br>
> One further check I would recommend. You gave an example of a noninteger, 61143.000001, obtained using 'format long'. I wish you had done 'format hex' on the number so the individual bits could be deciphered from the hex digit display. The number is off from the exact integer 61143 down somewhere in the lower 18 bits out of a total of 53. I wonder what those errant bits are. I am also quite startled that 'round' is incapable of clearing them away if that is what you are saying.<br>
> <br>
> Roger Stafford<br>
<br>
<br>
Regaeding the usage of 'round', in one of my trials to solve the problem I did the following:<br>
<br>
dilution = rand (size(S)) > ((length(S)  N0) / length(S));<br>
AA = round (find(dilution));<br>
if sum (mod (AA, 1)) ~=0,<br>
error ('Noninteger index !!!')<br>
end;<br>
<br>
Surprisingly, I still got the same error message after rounding the indices, but I didn't check the 'round' issue any further.<br>
<br>
Machinerelated (or maybe Matlab version related)? I also suspected there was something about it.<br>
The code was run so far on 3 different machines with different Matlab versions, but the problem appeared only on 2 of them.<br>
<br>
Happy new year,<br>
Tamar.<br>

Thu, 01 Jan 2009 18:06:02 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619483
Matt
<br>
> Regaeding the usage of 'round', in one of my trials to solve the problem I did the following:<br>
> <br>
> dilution = rand (size(S)) > ((length(S)  N0) / length(S));<br>
> AA = round (find(dilution));<br>
> if sum (mod (AA, 1)) ~=0,<br>
> error ('Noninteger index !!!')<br>
> end;<br>
<br>
That is pretyt bizarre. It might be good to see the full original code.

Fri, 02 Jan 2009 00:10:04 +0000
Re: 'find' returns noninteger indices (potential bug?)
http://www.mathworks.com/matlabcentral/newsreader/view_thread/241724#619504
Paul
"Matt " <mjacobson.removethis@xorantech.com> wrote in message <gjj0m9$lne$1@fred.mathworks.com>...<br>
> <br>
> > Regaeding the usage of 'round', in one of my trials to solve the problem I did the following:<br>
> > <br>
> > dilution = rand (size(S)) > ((length(S)  N0) / length(S));<br>
> > AA = round (find(dilution));<br>
> > if sum (mod (AA, 1)) ~=0,<br>
> > error ('Noninteger index !!!')<br>
> > end;<br>
> <br>
> That is pretyt bizarre. It might be good to see the full original code. <br>
<br>
Any chance this is being run on one of the old pentium processors that had the math/divide flaw hardwired into the chip?