On 1/3/2013 1:05 AM, Bruno Luong wrote: > majeti dinesh <email@example.com> wrote in message > <firstname.lastname@example.org>... >> Can you explain with some code as to how to use try...catch? > > I think try/catch suggestion is not good, Inf and NaN result from an > arithmetic expression is not an error, thus cannot be catch.
Yeah, I realized that later...a shortcoming in Matlab that can't set FP error condition flag dynamically for such things... :(
OP -- you'll just have to catch the problem case of u1==1 and make a fixup either before or after depending on what you want/need.
You could just generate the variate then replace NaN or Inf w/ another value or test the rnv u1 and reject the value 1 before the computation--your choice again depending on the need.
It's only the u1==1 that is causing the problem if the previous case is the only place like this in your code--try