discrete time signals.pdf

Upload: 201011892

Post on 08-Aug-2018

235 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/22/2019 Discrete time signals.pdf

    1/13

    Discrete-Times Signal and Systems:

    1/1

    FACULTY OF ENGINEERING AND THE BUILT

    ENVIRONMENT

    DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING

    SCIENCES

    DIGITAL SIGNAL PROCESSING3B21

    DISCRETE-TIMES SIGNAL AND SYSTEMS

    P.N Mbewe

    201011892

    27 October 2013

    DEPARTMENT OF ELECTRICAL AND ELECTRONIC ENGINEERING

    SCIENCES

    DIGITAL SIGNAL PROCESSING3B21

    DISCRETE-TIMES SIGNAL AND SYSTEMS

  • 8/22/2019 Discrete time signals.pdf

    2/13

    Discrete-Times Signal and Systems:

    2/2

    1. Matlab help functions1.1

    linespace: creates two vectors between two numbers in Matlab with equal length orgaps 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.

    sinisa function that is used to plot a sin wave.

    1.2

    (a) and (b)

    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).

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

    -0.5

    0

    0.5

    1

    time [s]

    amplitude[V]

    sin(2*pi*f*t), f=1

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

    -0.5

    0

    0.5

    1

    time [s]

    amplitude[V]

    sin(2*pi*f*t), f=2

  • 8/22/2019 Discrete time signals.pdf

    3/13

    Discrete-Times Signal and Systems:

    3/3

    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.

    Figure 3: frequency 4Hz

    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.

    Figure 5: frequency 9Hz

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

    -0.5

    0

    0.5

    1

    time [s]

    amplitude[V]

    sin(2*pi*f*t), f=4

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

    -0.5

    0

    0.5

    1

    time [s]

    amplitude[V]

    sin(2*pi*f*t), f=5

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

    -0.5

    0

    0.5

    1

    time [s]

    amplitude[V]

    sin(2*pi*f*t), f=19

  • 8/22/2019 Discrete time signals.pdf

    4/13

    Discrete-Times Signal and Systems:

    4/4

    Figure 6: frequency 49Hz

    d)

    Figure 7 : f =50Hz

    By shifting the position of samples by 1/200s of a sine function with 50 cycles, results to the followingconclusion. 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 xis 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.

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

    -0.5

    0

    0.5

    1

    time [s]

    amplitude[V]

    sin(2*pi*f*t), f=49

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

    -0.5

    0

    0.5

    1

    time [s]

    amplitude[V]

    sin(2*pi*f*t), f=50

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

    -0.5

    0

    0.5

    1

    time [s]

    amplitude[V]

    sin(2*pi*f*t), f=25

  • 8/22/2019 Discrete time signals.pdf

    5/13

    Discrete-Times Signal and Systems:

    5/5

    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.

    Figure 8Spectra of the analog signal.

    Figure 9 - Spectra of the digital signal.

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-1

    -0.5

    0

    0.5

    1

    time [s]

    amplitude[V]

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

    0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-3

    -2

    -1

    0

    1

    2

    3

    0 20 40 60 80 100 1200

    20

    40

    60

    80

    100

  • 8/22/2019 Discrete time signals.pdf

    6/13

    Discrete-Times Signal and Systems:

    6/6

    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.

    0 20 40 60 80 100 1200

    20

    40

    60

    80

    100

  • 8/22/2019 Discrete time signals.pdf

    7/13

    Discrete-Times Signal and Systems:

    7/7

    PART/OUTCOME 2

    DFT and FFT

    2.1 implementing the dft function

    The dft function was implemented using the following code and algorithm.

    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 0

    ans =

    2.0000 0 - 0.0000i

    Both answers are similar.

    This shows that the above constructed function Dftdir yields the same results as fft Matlab function .

    Code:

    functionX=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

    fork=0:N-1;%loop structure to call the function when requiredX(k+1)=0;forn=[0:N-1];

    w=W.^(n*k);X(k+1)=X(k+1)+x(n+1)*w;endend;

  • 8/22/2019 Discrete time signals.pdf

    8/13

    Discrete-Times Signal and Systems:

    8/8

    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.

    The result of the plots is shown below.

    Figure 11; dftdir

    0 200 400 600 800 1000 12000

    100

    200

    300

    400

    500

    600

    Fourier transform calculated with DFTdir

    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')

  • 8/22/2019 Discrete time signals.pdf

    9/13

    Discrete-Times Signal and Systems:

    9/9

    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.

    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 thecomputation takes place or is done.

    0 200 400 600 800 1000 12000

    100

    200

    300

    400

    500

    600

    Fourier transform calculated with fft

    Code:

    t=linspace(0,1,1023);y = sin(2*pi*25*t);tics1=DFTdir(y)

    toc

  • 8/22/2019 Discrete time signals.pdf

    10/13

    Discrete-Times Signal and Systems:

    10/10

    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 fftfunction computes the result a lot faster than the DFTdirfunction 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

  • 8/22/2019 Discrete time signals.pdf

    11/13

    Discrete-Times Signal and Systems:

    11/11

    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.

    0 200 400 600 800 1000 1200

    0

    50

    100

    0 200 400 600 800 1000 12000

    0.5

    1

    1.5x 10

    -9

    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

  • 8/22/2019 Discrete time signals.pdf

    12/13

    Discrete-Times Signal and Systems:

    12/12

    2.3

    a) and b)

    The developed DFTdir

    s1 =

    Columns 1 through 5

    36.0000 -2.5355 - 0.9497i -7.0000 - 3.0000i 4.5355 -

    8.9497i -2.0000 + 0.0000i

    Columns 6 through 8

    4.5355 + 8.9497i -7.0000 + 3.0000i -2.5355 + 0.9497i

    The built in fft function in Matlab

    s2 =

    Columns 1 through 5

    36.0000 -2.5355 - 0.9497i -7.0000 - 3.0000i 4.5355 -8.9497i -2.0000

    Columns 6 through 8

    4.5355 + 8.9497i -7.0000 + 3.0000i -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:

    functionx=IDFT(X)N=length(X);DFTdir = Xw=exp((j)*(2*pi)/N);fork=0:N-1;%loop structure to call the function when requiredx(k+1)=0;forn=[0:N-1];

    W=w.^(n*k);x(k+1)=x(k+1)+X(n+1)*W;endend;

  • 8/22/2019 Discrete time signals.pdf

    13/13

    Discrete-Times Signal and Systems:

    13/13

    [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.

    References