|
"Andrey Kazak" <AK@nospam.ru> wrote in message <fl9lsl$ba0$1@fred.mathworks.com>...
> Hallo!
>
> I try to calculate an amplitude and phase Fourier spectrum
> of a one-sided exponential signal in the following way:
>
> ---CODE---
> Fs = 10000; % Sampling frequency, Hz
> dt = 1/Fs; % Sample time
> L = 10001; % Length of signal
>
> t = (0:L-1)*dt; % Time vector
>
> A=1; % Exponent multiplier
> k=30; % Exponent k
>
> % One-sided exponential definition
> s=A*exp(-1*k*t);
>
> % Signal graphical output
> plot(t, s, 'DisplayName', 's', 'YDataSource', 's'); figure(gcf)
> %%
>
> %dw=2*pi/((length(s)-1)*dt);
> %w=(0:1:(length(s)-1))*dw;
>
> % Frequency vector definition
> df=1/((length(s)-1)*dt);
> f=(0:1:(length(s)-1))*df;
>
> % Complex Fourier spectrum calculaiton
> z=fft(s)*dt;
>
> % Amplitude Fourier spectrum calculaiton
> p=abs(z);
>
> % Amplitude Fourier spectrum graphical output
> plot(f,p);
>
> title('Amplitude Spectrum of Signal')
> xlabel('Frequency (Hz)')
> ylabel('|S(jf)|')
>
> %%
> % Phase Fourier spectrum calculaiton
> ph=angle(z);
>
> % Phase Fourier spectrum graphical output
> plot(f,ph);
>
> title('Phase Spectrum of Signal')
> xlabel('Frequency (Hz)')
> ylabel('Angle(S(jf))')
> ---CODE---
>
> Amplitude Fourier spectrum values (vector p) are correct
> with precision of 0.0001 (I suppose it's related to finite
> length of the exponential signal). However, phase Fourier
> spectrum values (vector ph) have very unclear behaviour - on
> the low frequencies they decrease and on high frequencies
> they increase, instead of steadily decrease from 0 to -Pi/2...
>
> Most likely I'm doing a wrong thing.
>
> Could you please help me to figure out my mistake?
>
> Thank you in advance for you answer!
>
> P.S. Happy New 2008 Year to Everyone!
Hey Everyone, This was very useful and Thanks,
The phase spectrum however noise because of computational errors that are magnified. All the phases for frequencies that are zero are meaningless mathematically however the noise wouldn't let you see it.
To Visualize the phase spectrum add the following line
phi=phi_duplicate;
phi(phi_duplicate < max(abs(phi)))=0;
this helps set all the unwanted phases to zero.
Thank you and you are Welcome
V Vale
|