100% found this document useful (1 vote)
295 views13 pages

Discrete Time Signals PDF

This document discusses discrete-time signals and systems. It begins by explaining how to create discrete sinusoidal signals using Matlab and how frequency relates to the number of cycles in a given time period. It shows examples of signals at different frequencies and discusses issues like distortion that can occur. It then covers implementing the discrete Fourier transform (DFT) and compares results to Matlab's built-in fast Fourier transform (FFT) function. Finally, it discusses the FFT algorithm and compares computation time between the implemented DFT and FFT functions.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
295 views13 pages

Discrete Time Signals PDF

This document discusses discrete-time signals and systems. It begins by explaining how to create discrete sinusoidal signals using Matlab and how frequency relates to the number of cycles in a given time period. It shows examples of signals at different frequencies and discusses issues like distortion that can occur. It then covers implementing the discrete Fourier transform (DFT) and compares results to Matlab's built-in fast Fourier transform (FFT) function. Finally, it discusses the FFT algorithm and compares computation time between the implemented DFT and FFT functions.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Discrete-Times Signal and Systems:

FACULTY OF ENGINEERING AND THE BUILT ENVIRONMENT


DEPARTMENT OF OF ELECTRICAL ELECTRICAL AND AND ELECTRONIC ELECTRONIC ENGINEERING ENGINEERING DEPARTMENT SCIENCES SCIENCES

DIGITAL SIGNAL PROCESSING3B21 DIGITAL SIGNAL PROCESSING3B21

DISCRETE-TIMES SIGNAL AND SYSTEMS DISCRETE-TIMES SIGNAL AND SYSTEMS P.N Mbewe 201011892 27 October 2013
1/1

Discrete-Times Signal and Systems:

1. Matlab help functions 1.1 linespace: creates two vectors between two numbers in Matlab with equal length or gaps between the two vectors . Linespace (1, 1, 50) creates time vector from 1 to 50 by incrementing by 1 each time.
Stem is used to plot waves or functions in a digital format instead of analogue. Plots the function in discrete time. sinis a function that is used to plot a sin wave.

1.2 (a) and (b)

sin(2*pi*f*t), f=1 1 0.5 0 -0.5 -1

amplitude [V]

0.1

0.2

0.3

0.4

0.5 time [s]

0.6

0.7

0.8

0.9

Figure 1 : discrete sinusoidal signal (0-1)

c) The above sinusoidal signal represents a digital signal. The signal is obtained by use of the stem function .The sine wave signal with a frequency of 1Hz. In this particular signal, 101 samples were taken in 1 period resulting n the above signal .The period of the signal is found to be 1s .(T=1s).

sin(2*pi*f*t), f=2 1 0.5 0 -0.5 -1

amplitude [V]

0.1

0.2

0.3

0.4

0.5 time [s]

0.6

0.7

0.8

0.9

2/2

Discrete-Times Signal and Systems:


Figure 2: sinusoidal signal with frequency 2Hz

By adjusting the frequency to 2Hz it is observed from the results that there are two cycles in one period. Frequency specifies how many cycles are achieved per second to a specific digital signal that has been created. To verify this theory, a couple of plots of digital sine signals are created at different frequencies. Note that as the frequency increases, there are fewer samples per cycle seen. The following signal shows the relationship between the number of cycles and frequency .in the Figures bellow shows that when the frequency is increased more number of cycles is obtained in the period of 1 second.
sin(2*pi*f*t), f=4 1 0.5 0 -0.5 -1

amplitude [V]

0.1

0.2

0.3

0.4

0.5 time [s]

0.6

0.7

0.8

0.9

Figure 3: frequency 4Hz


sin(2*pi*f*t), f=5 1 0.5 0 -0.5 -1

amplitude [V]

0.1

0.2

0.3

0.4

0.5 time [s]

0.6

0.7

0.8

0.9

Figure 4:frequency of 5Hz

It was observed that of some frequencies the sinusoidal signal had distortions .this occurred when the frequency of the function result in the irrational fraction with the sampling frequency .where the fundamental frequency fo = fs/f results in a rational frequency. The following figures shows the case.
sin(2*pi*f*t), f=19 1 0.5 0 -0.5 -1

amplitude [V]

0.1

0.2

0.3

0.4

0.5 time [s]

0.6

0.7

0.8

0.9

Figure 5: frequency 9Hz

3/3

Discrete-Times Signal and Systems:

sin(2*pi*f*t), f=49 1 0.5 0 -0.5 -1

amplitude [V]

0.1

0.2

0.3

0.4

0.5 time [s]

0.6

0.7

0.8

0.9

Figure 6: frequency 49Hz

d)
sin(2*pi*f*t), f=50 1 0.5 0 -0.5 -1

amplitude [V]

0.1

0.2

0.3

0.4

0.5 time [s]

0.6

0.7

0.8

0.9

Figure 7 : f =50Hz

By shifting the position of samples by 1/200s of a sine function with 50 cycles, results to the following conclusion. When shifting the position of samples by any value between 0 and 100 in the denominator or having a shift bound by the following expression ([ x) where x is any value greater than 1, this results in a signal that is distorted. However, when a from the above expression is any value that is less than 1, this results in a sine wave or signal that has a reduced amplitude.

sin(2*pi*f*t), f=25 1 0.5 0 -0.5 -1

amplitude [V]

0.1

0.2

0.3

0.4

0.5 time [s]

0.6

0.7

0.8

0.9

4/4

Discrete-Times Signal and Systems:


sin(2*pi*f*t), f=-75 1 0.5 0 -0.5 -1

amplitude [V]

0.1

0.2

0.3

0.4

0.5 time [s]

0.6

0.7

0.8

0.9

After aliasing and a change of frequencies to 25, -25, 75, and 75; the signals looked the same with equal amplitudes. In the cases of 25Hz and -75Hz, the two signals look exactly the same, but with a 90 degrees phase shift, this also applies to the other two cases (-25Hz and 75Hz). 25Hz and 75Hz signals look exactly the same. This implies as suing a cosine function at a 90 phase shift result the same signal as if a a non shifted sinusoidal signal was used.

1.3 (a ,b and c) Superposition of two sinusoids is investigated in the following question, thus because the two functions are not in phase, this results in cases where the two signals add and cases where the two signals subtract each other. Again because the frequency of each function is not the same, there might be distortions.
3 2 1 0 -1 -2 -3 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

Figure 8 Spectra of the analog signal.


100 80 60 40 20 0

20

40

60

80

100

120

Figure 9 - Spectra of the digital signal.

5/5

Discrete-Times Signal and Systems:


100 80 60 40 20 0

20

40

60

80

100

120

Figure 10

The spectrum are plotted in the above two figures. The spectrum has four bandwidths and it was seen that the spectrum will remain the same irrespective of whether the other function is aliased or not.

References
[1] William H. Tranter, D. Ronald Fannin Rodger E. Ziener, Signals & Systems - Continuous and Discrete , 4th ed., Marcia Horton, Ed. Colorado Springs/Rolla, United States of America: Pearson Education International, 1998.

6/6

Discrete-Times Signal and Systems:

PART/OUTCOME 2 DFT and FFT


2.1 implementing the dft function The dft function was implemented using the following code and algorithm.
Code:
function X=DFTdir(x) % assigns X to function dft wih parameter x . N=length(x); W=exp((-j)*(2*pi)/N);% equation required to perform mathematical calculation for k=0:N-1;%loop structure to call the function when required X(k+1)=0; for n=[0:N-1]; w=W.^(n*k); X(k+1)=X(k+1)+x(n+1)*w; end end;

a)
The function created above was tested against the built in function already installed in Matlab which is called fft. Few inputs were investigated using both the DFTdir created and fft built in Matlab function. The results were as follows

Input: s = [1 1] Output: ans = 2 ans = 2.0000

0 0 - 0.0000i

Both answers are similar. This shows that the above constructed function Dftdir yields the same results as fft Matlab function .

7/7

Discrete-Times Signal and Systems:


b)

The following code is construed generate 1024 samples spanning a few cycles Of a sine wave, and plot the absolute values of the transform calculated by DFTdir together with values as calculated by fft.
Code:
y = sin(2*pi*25*t); s1=DFTdir(y);s3=abs(s1); s2=fft(y);s4=abs(s2); figure; plot(s3) title('Fourier transform calculated with DFTdir');figure;plot(s4) title('Fourier transform calculated with fft')

The result of the plots is shown below.


Fourier transform calculated with DFTdir 600

500

400

300

200

100

200

400

600

800

1000

1200

Figure 11; dftdir

8/8

Discrete-Times Signal and Systems:


Fourier transform calculated with fft 600

500

400

300

200

100

200

400

600

800

1000

1200

Figure 12:fft

From the two plots the absolute values of the transform calculated by DFTdir together with

values as calculated by fft.The two plos shows the same plots even though they use the different functions, fft and dftdir. So this suggests that the function which was created is accurate.

c) The Estimated time deference needed by the two functions by using tic and toc, which work together to measure elapsed time. The following code shows the elapsed time using tic and toc.
Code:
t=linspace(0,1,1023); y = sin(2*pi*25*t); tic s1=DFTdir(y) toc

Elapsed time is 2.094658 seconds. Elapsed time is 2.011156 seconds. From these three elapsed time values, the average was calculated and was found to be 2.051134 seconds (For the function which was created). It is evident that the computation time decreases every time the computation takes place or is done.

9/9

Discrete-Times Signal and Systems:


Elapsed time is 0.086305 seconds. Elapsed time is 0.000114 seconds. Elapsed time is 0.000075 seconds. Elapsed time is 0.000109 seconds. Average = 0.021651 seconds The difference in time needed for the two functions is 2.051134-0.021651=2.029483 seconds. This suggests that the fft function computes the result a lot faster than the DFTdir function which follows a theoretical manner of computing the Fourier transform, hence it has the name fast Fourier transform.

d) The complexity order of the dft is higher compared to the complexity order of the fft, O(NlogN)
To accelerate the fast Fourier transform (FFTij), the values of N have to be increased, thus more time is taken to perform the calculation.

2.2
a, b & c) Code:

N=2 m=log2(N) for K=0:N-1 NADDR=0 IADDR=K for I=0:m-1 RMNDR=mod(IADDR,2) NADDR=NADDR+RMNDR*2^(m-1-I) NADDR=floor(IADDR/2) end newdata(naddr) := data(k) end for S=1:m

10/10

Discrete-Times Signal and Systems:

P=N/BSEP BWIDTH=BSEP/2 for J=0:(BWIDTH-1) R=J THETA=(2*pi*R)/N WN=exp(-j*THETA) for TOPVAL=J:BSEP:N-1 BOTVAL=TOPVAL+BWIDTH TEMP=X(BOTVAL)*WN X(BOTVAL)=X(TOPVAL+1)-TEMP X(TOPVAL+1)=X(TOPVAL+1)+TEMP
100

50

0 x 10
-9

200

400

600

800

1000

1200

1.5

0.5

200

400

600

800

1000

1200

Figure 13

To accelerate the fast Fourier transform (FFTij), the values of N have to be increased, thus more time is taken to perform the calculation.

11/11

Discrete-Times Signal and Systems:

2.3
a) and b) The developed DFTdir s1 = Columns 1 through 5 36.0000 -2.5355 - 0.9497i 8.9497i -2.0000 + 0.0000i Columns 6 through 8 4.5355 + 8.9497i -7.0000 + 3.0000i -2.5355 + 0.9497i -7.0000 - 3.0000i 4.5355 -

The built in fft function in Matlab s2 = Columns 1 through 5 36.0000 -2.5355 - 0.9497i 8.9497i -2.0000 Columns 6 through 8 4.5355 + 8.9497i -7.0000 + 3.0000i

-7.0000 - 3.0000i

4.5355 -

-2.5355 + 0.9497i

All the coefficients correspond to a sample value nT where T is a constant, this means that 36 correspond to sample number T, -25 -0.95i corresponds to 2T, -7.0000 - 3.0000i corresponds to 3T and so on until 2.5355 + 0.9497i which corresponds to 8T. The following function could be used to obtain back the original discrete functions: Code:
function x=IDFT(X) N=length(X); DFTdir = X w=exp((j)*(2*pi)/N); for k=0:N-1;%loop structure to call the function when required x(k+1)=0; for n=[0:N-1]; W=w.^(n*k); x(k+1)=x(k+1)+X(n+1)*W; end 12/12 end;

Discrete-Times Signal and Systems:

References
[1] William H. Tranter, D. Ronald Fannin Rodger E. Ziener, Signals & Systems - Continuous and Discrete , 4th ed., Marcia Horton, Ed. Colorado Springs/Rolla, United States of America: Pearson Education International, 1998.

13/13

You might also like