i still feel like a matlab newbie

alpha approaches r as m approaches 0 in
alpha=(-2+m+sqrt(4-4*m+m^2+8*m*r))/(2*m)
but
>>m=0.000000000000000001;r=42;(-2+m+sqrt(4-4*m+m^2+8*m*r))/(2*m)
ans = 0. :-(
does matlab have any built-in function (like mathematica's Chop) that
replaces near-0 values by 0, or do I have to write one myself? (I could
use it to replace near-0 values of m by 0, and then replace all zeroes by
0.0001. Or is there an even more elegant solution?)
--
Joshua A. Solomon
http://www.staff.city.ac.uk/~solomon
thanks
j
--
Joshua A. Solomon
http://www.staff.city.ac.uk/~solomon




On 29/02/2012 00:55, "Diederick C. Niehorster" <dcnieho@...> wrote:

>
>
>
>
>
>
> I'm not aware of any such function, but
>
>function dat = chop(dat,tol)
>% tol is optional, defaults to eps
>if nargin<2
> tol = eps;
>end
>
>dat(abs(dat)<tol) = 0;
>
>
>Untested.
>
>Best,
>Dee
>
>
>On Wed, Feb 29, 2012 at 03:58, Solomon, Joshua <J.A.Solomon@...>
>wrote:
>
>
>
>
>
>
>
>
> alpha approaches r as m approaches 0 in
>alpha=(-2+m+sqrt(4-4*m+m^2+8*m*r))/(2*m)
>but
>>>m=0.000000000000000001;r=42;(-2+m+sqrt(4-4*m+m^2+8*m*r))/(2*m)
>ans = 0. :-(
>does matlab have any built-in function (like mathematica's Chop) that
>replaces near-0 values by 0, or do I have to write one myself? (I could
>use it to replace near-0 values of m by 0, and then replace all zeroes by
>0.0001. Or is there an even more elegant solution?)
>--
>Joshua A. Solomon
>http://www.staff.city.ac.uk/~solomon
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>