Clear Filters
Clear Filters

Why do I get a phase = 0 when I add a constant to a sinusoidal wave?

1 view (last 30 days)
Hi everyone, say you have x = A*sin(wt + phi) + A0 where A0 is a constant. When I do fft on x and try to get the phase, I always get 0. Why is that? Is it because the wave is shifted up so it is no longer considered a sinusoidal wave? Thank you
  2 Comments
Nina
Nina on 22 Feb 2013
Edited: Nina on 22 Feb 2013
Well, I tried few things for example, A =2, w=2*pi*10, phi = pi/8 and A0 = 120, and just random values over all...and the phase from fft always end up 0. This is the code I am using: clc clear
A = 10;
B= 17.6;
C=2;
D=11.2;
Ao = 10;
phi1 =pi/8;
phi2 =pi/12;
phi3 =pi/4;
phi4 =pi/3;
Fs = 2000;
t = 0:1/Fs:2-1/Fs
x=(A*sin(2*pi*10*t+phi1)+B*cos(2*pi*5*t+phi2)+C*sin(2*pi*2*t+phi3)+D*cos(2*pi*t*1+phi4)) + Ao;
n=ceil(log2(length(x))); % Or you can use the function nextpow2
xdft = fft(x,length(x));
fx = xdft;
fx=2*fx/length(x); % This operation is Adjusting the Magnitudes A,B,C,D
f=(Fs/2^n)*(0:2^(n-1)-1);
abs(fx(1:2^(n-1)));
FT_power2 =abs(fx(1:2^(n-1)));% abs(fx).^2;
FT_phase2= (((angle(fx))) * 180/pi);
[c2,i2] = max(FT_power2);
FT_power2;
FT_phase2;
phase = (FT_phase2(i2))%this is given in degrees

Sign in to comment.

Accepted Answer

Wayne King
Wayne King on 22 Feb 2013
That should not happen
Fs = 1000;
t = 0:1/Fs:1-1/Fs;
x = 2+cos(2*pi*100*t-pi/4);
xdft = fft(x);
% now look at the DFT corresponding to 100 Hz
xdft(101)
angle(xdft(101))
Can you please show your code, as you see above, adding a DC shift does not give you a phase of 0.
  2 Comments
Nina
Nina on 22 Feb 2013
Also, what is a DC shift? what does DC stand for? Thank you
Wayne King
Wayne King on 22 Feb 2013
direct current. It is a synonym for a shift in the mean value of the waveform, or the equivalently the frequency content at f = 0.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!