# Determing the Phase Angle of the following code: [closed]

I'm trying to determine the phase of xx after the code is run. You shouldn't need to actually run it to determine it however, as it is unclear on the graph. The two phases present appear to be (-3*j) which is simply -3 in a cosine, and (-1*j) or simply -1 in a cosine. I am not sure how to combine them however, and determine the final phase of xx.

tt = -100 : 1/783300 : 100;
zz = 10*exp(-3*j)*exp(j*7833*pi*tt);
for k=1:3
zz = 2*zz.*exp(-1*j).*exp(j*7833*pi*tt)
end
xx = real(zz);


I hope this is fitting for EE!

-

## closed as off topic by Brian Carlton, stevenvh, Dave Tweed, embedded.kyle, Connor WolfNov 6 '12 at 11:21

Questions on Electrical Engineering Stack Exchange are expected to relate to electronics design within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

... (-3*j) which is simply -3 in a cosine, and (-1*j) or simply -1 in a cosine

Based on this, I think you have a little bit of confusion about complex numbers.

The relationship you want to keep in mind is

$exp(j\theta) = \cos(\theta) + j\sin(\theta)$,

so neither of your examples gives a pure real or imaginary number.

Another important relationship is true for any exponential:

$x^y \cdot x^z = x^{(y+z)}$.

To answer the specific question, since k never appears inside the for loop, it's pretty easy to unwrap the whole thing:

zz = 10 * exp(-3*j) * exp(j*7833*pi*tt) * 2 * exp(-1*j) * exp(j*7833*pi*tt) * 2 * exp(-1*j) * exp(j*7833*pi*tt) * 2 * exp(-1*j) * exp(j*7833*pi*tt)

Now you can gather like terms:

zz = 10 * 2 * 2 * 2 * exp(-3*j) * exp(-1*j) * exp(-1*j) * exp(-1*j) * exp(j*7833*pi*tt) * exp(j*7833*pi*tt) * exp(j*7833*pi*tt) * exp(j*7833*pi*tt)

The real factors don't affect the gain, so ignore those. Then you have

zz = mag * exp(j * (-3 + -1 + -1 + -1 + 7833*pi*tt + 7833*pi*tt + 7833*pi*tt + 7833*pi*tt))

or

zz = mag * exp(j * (-6 + 4*7833*pi*tt) )

Now it depends what you mean by phase, since you seem to be representing a time-varying signal. If you mean the relative phase compared to some other signal with the same frequency, the -6 term is what matters. Your phase is -6 radians. If you mean the instantaneous phase at each time sample, then it's -6 + 31,332$\pi$ radians per time unit.

-
I wanted to put them in the same format OP used. –  The Photon Sep 28 '12 at 17:09
I'm not entirely sure... The course is Digital Signal Processing. For example: 4cos(40pi + pi/2) can be represented as 4exp(j*pi/2) * exp(40*pi*t) -> complex exponential form. I'm looking for the phase-shift of the final, resultant vector. –  Brandon Smith Sep 28 '12 at 19:50
@BrandonSmith, I think you're missing a "j" in what you just wrote. exp(40*pi*t) would have magnitude varying from 0 to infinity, while 4*cos(anything) is always between -4 and +4. –  The Photon Sep 28 '12 at 22:46