Discrete Time Signals PDF
Discrete Time Signals PDF
DISCRETE-TIMES SIGNAL AND SYSTEMS DISCRETE-TIMES SIGNAL AND SYSTEMS P.N Mbewe 201011892 27 October 2013
1/1
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.
amplitude [V]
0.1
0.2
0.3
0.4
0.6
0.7
0.8
0.9
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).
amplitude [V]
0.1
0.2
0.3
0.4
0.6
0.7
0.8
0.9
2/2
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.6
0.7
0.8
0.9
amplitude [V]
0.1
0.2
0.3
0.4
0.6
0.7
0.8
0.9
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.6
0.7
0.8
0.9
3/3
amplitude [V]
0.1
0.2
0.3
0.4
0.6
0.7
0.8
0.9
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.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.
amplitude [V]
0.1
0.2
0.3
0.4
0.6
0.7
0.8
0.9
4/4
amplitude [V]
0.1
0.2
0.3
0.4
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
20
40
60
80
100
120
5/5
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
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
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
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')
500
400
300
200
100
200
400
600
800
1000
1200
8/8
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
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
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
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;
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