LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Take the real component of logarithms of negative numbers

Solved!
Go to solution

I'm trying to take the log of a number, and I need the real component. For example: log(-5) = 0.698970004 + 1.36437635 i

 

I need to be able to take the 0.698970004 and use that, whereas Labview just says its NAN.

 

I just figured out I can cast the inputs as a CPD, but then I'm still not sure how to convert back to having just the real component.

 

Ideas?

 

Thank you

0 Kudos
Message 1 of 4
(3,090 Views)
Solution
Accepted by topic author bobholmgren

The trick is to set the datatype representation of the number going into the Logarithm primitive. After that, it's easy to divide the complex number into real and imaginary components:

 

19915iEC18749416FD522D

Message 2 of 4
(3,082 Views)

And if your original datatype is not a complex datatype, be sure you "Type Convert" the wire, not "Typecast" the wire. There's a difference in semantics and in function. Type Convert preserves the values, while Typecast preserves bits.

Message 3 of 4
(3,080 Views)

Thank you, exactly the answer I was looking for

0 Kudos
Message 4 of 4
(3,074 Views)