@davidlimtw wrote:
Hi Werner,
is this the correct function to make the non real number zero?
No, if the goal is to only replace every non-real number by zero.
For example if the non-real number is (0.3+0.6i) m, then its replace by the positive real part 0.3 m by your approach and not by zero.
Your approach works as long a the real parts are all negative like in (-0.3 +0.6i) m which may be the case for your example.
Furthermore your approach additionally replaces all negative real values by zero. Not sure if that was intended.
If you really just want to replace every non-real value by 0, you could do it that way

What your approach actually does is using just the real part of the solution

and the replacing negative values by zero, no matter if the solution was non-real or real.
BTW, if you wish to suppress non-real solutions altogether you can replace the 0 m in my first approach by a NaN, so these values aren't plotted at all.

And in case you want to suppress non-real values but additionally want to replace negative real values by 0m, you could do it that way

Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.



