On 08/11/10 9:44 AM, Sean wrote:
> "Edman " <maver1ck01@aol.com> wrote in message
> <ib955l$hkl$1@fred.mathworks.com>...
>> I'm trying to run through an array of x values ranging from [0: .5:
>> 90] with a for loop. Within the for loop, I have equations that return
> cL(cL==1.5)
> Will give you a logical vector that is true to the index you want.
It happens that N+0.5 for N an integer in 0 to 89, are values that are
exactly representable in binary floating point, so the suggested code
can actually work. It is, however, not recommended that one rely upon
that property, as relatively few short decimal fractions are exactly
representable in binary floating point, and coding in terms of one of
the few that happen to work tends to lead to programmer laziness about
dealing with the difficulties in floating point representation. For
example, if the array of x values were generated as [0 : .1 : 90]
instead, it is not promised that the _exact_ value 1.5 would be in the
array.
