I have a voice signal a. Lets say its a sine with x Hz.
Length and sampling frequency are writen below:
fs = 100000; % Sampling frequency T = 1/fs; % Sample time L = 100000; % Length of signal t = (0:L-1)*T; % Time vector (s)
Here is the FFT of this signal in Hertz
NFFT = 2^nextpow2(L); ff = fs/2*linspace(0,1,NFFT/2+1); A = fft(a,NFFT)/L; plot(ff,2*abs(A(1:NFFT/2+1)));xlabel('freq (Hz)'); ylabel('|A(f)| ');grid
How can we apply a 90 degrees phase shift to this signal-a? Actually, we can estimate its type, frequency and amplitude by plotting it in time and freq. domain and then we can write it as something(2*pi*x*t). Then of course, shifted wave will become something(2*pi*x*t+pi/2). But we need a code that directly shift its phase 90 degrees.
Best regards Dave
If you have the Signal Processing Toolbox, you can use hilbert() to obtain the analytic signal and use the imaginary part.
n = 0:159; x = cos(pi/4*n); y = hilbert(x); plot(n,x,'b'); hold on; plot(n,imag(y),'r');
Note that with a frequency of pi/4 radians/sample, a phase shift of pi/2 is 2 samples, which is exactly what you get in imag(y).