Thread Subject: Calculation of phase spectrum for one-sided exponential signal...

Subject: Calculation of phase spectrum for one-sided exponential signal...

From: Andrey Kazak

Date: 31 Dec, 2007 02:58:30

Message: 1 of 3

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!

Subject: Calculation of phase spectrum for one-sided exponential signal...

From: VVale A

Date: 29 Sep, 2010 15:59:07

Message: 2 of 3

"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

Subject: Calculation of phase spectrum for one-sided exponential signal...

From: VVale A

Date: 29 Sep, 2010 16:29:06

Message: 3 of 3

"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!





TO quickly correct last post, I think the phase value for the frequency of interrest should be the lowest, my previous post picks the highest. To correct this try

phi_duplicate=phi;
phi(abs(phi_duplicate) <abs(0.0005))=10;
This accentuates the phase at the right fequency
Thanks

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
phase spectrum ... VVale A 29 Sep, 2010 12:04:28
calculation Andrey Kazak 30 Dec, 2007 22:05:07
fourier spectrum Andrey Kazak 30 Dec, 2007 22:05:07
exponent Andrey Kazak 30 Dec, 2007 22:05:07
rssFeed for this Thread

Contact us at files@mathworks.com