user3798269
user3798269

Reputation: 59

How to put real and imaginary components into one variable like in matlab

I have successfully computed the hilbert transform of a vector of floats. The output of this transform has the real components in out2[i][0], and the imaginary components in out2[i][1]. The problem is, I need to be able to divide as follows: [(out2[i][0] + out2[i][1]*I)/(out2[i-1][0] + out2[i-1][1]*I)]. The matlab equivalent of the hilbert transform spits out the results in the form

0.0440 - 0.0876i

0.0740 - 0.0309i

0.0790 - 0.0097i

0.0490 + 0.0458i

and I am trying to replicate the results in that form so that I can divide for example (0.0440 - 0.0876i)/(0.740-0.0309i).

My most recent attempt was based off of How to get Vector of Complex numbers from two vectors (real & imag) and was able to get the results to be in the following (real component, imaginary component) form:

(25.6853,12.4197)

(28.315,38.7512)

(24.6848,23.5361)

(1.31542,62.6511)

Does anyone have any suggestions as to how I should go about doing this?

Upvotes: 0

Views: 124

Answers (1)

fjardon
fjardon

Reputation: 7996

Complex numbers support the / operation: http://en.cppreference.com/w/cpp/numeric/complex/operator_arith3

Upvotes: 1

Related Questions