|
"Kiril " <kkirqkov@gmail.com> wrote in message <gs80et$daa$1@fred.mathworks.com>...
>
> > % If I understand, P is real & complex and you just want the real & > 0 part.
> > % So, add this to the end of your code (this works for this case),
> > % BUT THERE COULD BE NUMERICAL ACCURACY PROBLEMS IN GENERAL.
>
> Yes, but is in this calculation i always have only one real positive root i don't think that where is a problem with ACCURACY or if there is, please could u describe me why?
In general. roots might return a value of:
1000000 + 0.000001 i
Is that "real" enough for you?
If so, P(imag(P)==0 will fail.
That is all I was trying to covey.
In general, doing an equality test for floating point number is a bad idea.
They should be tested to within a tolerance (that you define).
|