basic simulation lab manual (1)

Upload: eswar-eswara

Post on 02-Jun-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/10/2019 Basic Simulation Lab Manual (1)

    1/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    1

    CONTENTS

    S.No Experiment Name Page No.

    1. Basic operations on matrices. 22. Generation on various signals and Sequences 7

    (periodic and aperiodic), such as unit impulse, unit step,square, sawtooth, triangular, sinusoidal, ramp, sinc.

    3. Operations on signals and sequences such as addition, 21multiplication, scaling, shifting, folding, computation ofenergy and average power.

    4. Finding the even and odd parts of signal/sequence 27and real and imaginary part of signal.

    5. Convolution between signals and sequences. 326. Auto correlation and cross correlation between 35

    signals and sequences.7. Verification of linearity and time invariance 39

    properties of a given continuous /discrete system.8. Computation of unit sample, unit step and sinusoidal 46

    response of the given LTI system and verifying itsphysical Realizability and stability properties.

    9. Gibbs phenomenon. 5010. Finding the Fourier transform of a given 52

    signal and plotting its magnitude and phase spectrum.

    11. Waveform synthesis using Laplace Transform. 5712. Locating the zeros and poles and plotting the

    pole zero maps in s-plane and z-plane for the given 61transfer function.

    13. Generation of Gaussian Noise(real and complex), 64computation of its mean, M.S. Value and its skew,

    kurtosis, and PSD, probability distribution function.14. Sampling theorem verification. 6715. Removal of noise by auto correlation/cross correlation. 7316. Extraction of periodic signal masked by noise 79

    using correlation.

    17. Verification of Weiner-Khinchine relations. 84

    18. Checking a random process for stationarity in wide sense. 86

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    2/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    2

    EXP.NO: 1

    BASIC OPERATIONS ON MATRICES

    Aim:To generate matrix and perform basic operation on matrices Using MATLAB

    Software.

    EQUIPMENTS:

    PC with windows (95/98/XP/NT/2000).

    MATLAB Software

    MATLAB on Matrices

    MATLAB treats all variables as matrices. For our purposes a matrix can be thought of asan array, in fact, that is how it is stored.

    Vectors are special forms of matrices and contain only onerow OR one column. Scalars are matrices with only one row AND one column.A matrix with only one

    row AND one column is a scalar. A scalar can be reated in MATLAB as follows: a_value=23a_value =23 A matrix with only one row is called a row vector. A row vector can be created in

    MATLAB as follows :

    rowvec = [12 , 14 , 63]rowvec =12 14 63

    A matrix with only one column is called a column vector. A column vector can becreated in MATLAB as follows:

    colvec = [13 ; 45 ; -2]colvec =1345-2

    A matrix can be created in MATLAB as follows:

    matrix = [1 , 2 , 3 ; 4 , 5 ,6 ; 7 , 8 , 9]matrix =1 2 34 5 67 8 9Extracting a Sub-Matrix

    A portion of a matrix can be extracted and stored in a smaller matrix byspecifying the names of both matrices and the rows and columns to extract. The syntax is:

    sub_matrix = matrix ( r1 : r2 , c1 : c2 ) ;

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    3/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    3

    Where r1 and r2 specify the beginning and ending rows and c1 and c2 specify thebeginning and ending columns to be extracted to make the new matrix.

    A column vector can beextracted from a matrix.

    As an example we create a matrix below: matrix=[1,2,3;4,5,6;7,8,9]matrix =1 2 34 5 67 8 9

    Here we extract column 2 of the matrix and make a column vector: col_two=matrix( : , 2)col_two =2 5 8

    A row vector can be extracted from a matrix.As an example we create a matrix below: matrix=[1,2,3;4,5,6;7,8,9]matrix =1 2 34 5 67 8 9

    Here we extract row 2 of the matrix and make a row vector. Note that the 2:2specifies the second row and the 1:3 specifies which columns of the row.

    rowvec=matrix(2 : 2 , 1 :3)rowvec =4 5 6 a=3; b=[1, 2, 3;4, 5, 6]b =1 2 34 5 6 c= b+a % Add a to each element of bc =4 5 67 8 9

    Scalar - Matrix Subtraction a=3; b=[1, 2, 3;4, 5, 6]b =1 2 34 5 6 c = b - a %Subtract a from each element of bc =-2 -1 01 2 3

    Scalar - Matrix Multiplication a=3;

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    4/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    4

    b=[1, 2, 3; 4, 5, 6]b =1 2 34 5 6 c = a * b % Multiply each element of b by ac =3 6 912 15 18

    Scalar - Matrix Division a=3; b=[1, 2, 3; 4, 5, 6]b =1 2 34 5 6 c = b / a % Divide each element of b by ac =0.3333 0.6667 1.00001.3333 1.6667 2.0000

    a = [1 2 3 4 6 4 3 4 5]

    a =

    1 2 3 4 6 4 3 4 5

    b = a + 2b =

    3 4 5 6 8 6 5 6 7

    A = [1 2 0; 2 5 -1; 4 10 -1]

    A =

    1 2 0

    2 5 -1

    4 10 -1

    B = A'

    B =

    1 2 4

    2 5 10

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    5/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    5

    0 -1 -1

    C = A * B

    C =

    5 12 24

    12 30 59

    24 59 117

    Instead of doing a matrix multiply, we can multiply the corresponding elements oftwo matrices or vectors using the .* operator.

    C = A .* B

    C =

    1 4 0

    4 25 -10

    0 -10 1

    Let's find the inverse of a matrix

    X = inv(A)

    X =

    5 2 -2

    -2 -1 1

    0 -2 1

    and then illustrate the fact that a matrix times its inverse is the identity matrix.

    I = inv(A) * A

    I =

    1 0 0

    0 1 0

    0 0 1

    to obtain eigenvalues

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    6/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    6

    eig(A)

    ans =

    3.7321

    0.2679

    1.0000

    as the singular value decomposition.

    svd(A)

    ans =

    12.3171

    0.5149

    0.1577

    CONCLUSION:Inthis experiment basic operations on matrices Using MATLAB

    have been demonstrated.

    3.perform following operations on any two matrices

    A+BA-BA*B

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    7/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    7

    A.*BA/BA./BA\BA.\BA^B,A.^B,A',A.

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    8/90

  • 8/10/2019 Basic Simulation Lab Manual (1)

    9/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    9

    Matlab program:

    %unit impulse generationclcclose alln1=-3;n2=4;n0=0;n=[n1:n2];x=[(n-n0)==0]stem(n,x)

    2)Unit Step Function u(t):

    b)Unit Step Sequence u(n): )={ 1, n 00, n < 0

    % unit step generationn1=-4;n2=5;n0=0;

    =

    00

    01)(

    t

    ttu

    =

    0)()()( dttdtttu

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    10/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    10

    [y,n]=stepseq(n0,n1,n2);stem(n,y);xlabel('n')ylabel('amplitude');title('unit step');

    Square waves: Like sine waves, square waves are described in terms of period,frequency and amplitude:

    Peak amplitude, Vp, and peak-to-peak amplitude, Vpp, are measured as you might

    expect. However, the rms amplitude, Vrms, is greater than that of a sine wave. Rememberthat the rms amplitude is the DC voltage which will deliver the same power as the signal.If a square wave supply is connected across a lamp, the current flows first one way andthen the other. The current switches direction but its magnitude remains the same. Inother words, the square wave delivers its maximum power throughout the cycle so thatVrmsis equal to Vp. (If this is confusing, don't worry, the rms amplitude of a square waveis not something you need to think about very often.)

    Although a square wave may change very rapidly from its minimum to maximumvoltage, this change cannot be instaneous. The rise timeof the signal is defined as thetime taken for the voltage to change from 10% to 90% of its maximum value. Rise times

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    11/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    11

    are usually very short, with durations measured in nanoseconds (1 ns = 10-9 s), ormicroseconds (1 s = 10-6s), as indicated in the graph

    % square wave wave generatorfs = 1000;t = 0:1/fs:1.5;x1 = sawtooth(2*pi*50*t);x2 = square(2*pi*50*t);subplot(2,2,1),plot(t,x1), axis([0 0.2 -1.2 1.2])xlabel('Time (sec)');ylabel('Amplitude'); title('Sawtooth Periodic Wave')subplot(2,2,2),plot(t,x2), axis([0 0.2 -1.2 1.2])xlabel('Time (sec)');ylabel('Amplitude'); title('Square Periodic Wave');subplot(2,2,3),stem(t,x2), axis([0 0.1 -1.2 1.2])xlabel('Time (sec)');ylabel('Amplitude');

    SAW TOOTH:The sawtooth wave (or saw wave) is a kind of non-sinusoidal waveform. It is

    named a sawtooth based on its resemblance to the teeth on the blade of a saw. Theconvention is that a sawtooth wave ramps upward and then sharply drops. However, thereare also sawtooth waves in which the wave ramps downward and then sharply rises. Thelatter type of sawtooth wave is called a 'reverse sawtooth wave' or 'inverse sawtoothwave'. As audio signals, the two orientations of sawtooth wave sound identical. Thepiecewise linear function based on the floor function of time t, is an example of asawtooth wave with period 1.

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    12/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    12

    A more general form, in the range 1 to 1, and with period a, is

    This sawtooth function has the same phase as the sine function. A sawtoothwave's sound is harsh and clear and its spectrum contains both even and odd harmonicsof the fundamental frequency. Because it contains all the integer harmonics, it is one ofthe best waveforms to use for synthesizing musical sounds, particularly bowed stringinstruments like violins and cellos, using subtractive synthesis.

    Applications

    The sawtooth and square waves are the most common starting points used tocreate sounds with subtractive analog and virtual analog music synthesizers.

    The sawtooth wave is the form of the vertical and horizontal deflection signals

    used to generate a raster on CRT-based television or monitor screens. Oscilloscopes alsouse a sawtooth wave for their horizontal deflection, though they typically use electrostaticdeflection.

    On the wave's "ramp", the magnetic field produced by the deflection yoke dragsthe electron beam across the face of the CRT, creating a scan line.

    On the wave's "cliff", the magnetic field suddenly collapses, causing the electronbeam to return to its resting position as quickly as possible.

    The voltage applied to the deflection yoke is adjusted by various means

    (transformers, capacitors, center-tapped windings) so that the half-way voltage on thesawtooth's cliff is at the zero mark, meaning that a negative voltage will cause deflectionin one direction, and a positive voltage deflection in the other; thus, a center-mounteddeflection yoke can use the whole screen area to depict a trace. Frequency is 15.734 kHzon NTSC, 15.625 kHz for PAL and SECAM)

    % sawtooth wave generatorfs = 10000;t = 0:1/fs:1.5;x = sawtooth(2*pi*50*t);subplot(1,2,1);plot(t,x), axis([0 0.2 -1 1]);xlabel('t'),ylabel('x(t)')title('sawtooth signal');N=2; fs = 500;n = 0:1/fs:2;x = sawtooth(2*pi*50*n);subplot(1,2,2);

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    13/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    13

    stem(n,x), axis([0 0.2 -1 1]);xlabel('n'),ylabel('x(n)')title('sawtooth sequence');

    Triangle wave

    A triangle wave is a non-sinusoidal waveform named for its triangular shape.Abandlimited triangle wave pictured in the time domain (top) and frequency domain(bottom). The fundamental is at 220 Hz (A2).Like a square wave, the triangle wavecontains only odd harmonics. However, the higher harmonics roll off much faster than ina square wave (proportional to the inverse square of the harmonic number as opposed tojust the inverse).It is possible to approximate a triangle wave with additive synthesis byadding odd harmonics of the fundamental, multiplying every (4n1)th harmonic by 1(or changing its phase by ), and rolling off the harmonics by the inverse square of theirrelative frequency to the fundamental.This infinite Fourier series converges to the trianglewave:

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    14/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    14

    To generate a trianguular pulseA=2; t = 0:0.0005:1;x=A*sawtooth(2*pi*5*t,0.25); %5 Hertz wave with duty cycle 25%plot(t,x);gridaxis([0 1 -3 3]);

    %%To generate a trianguular pulsefs = 10000;t = -1:1/fs:1;x1 = tripuls(t,20e-3); x2 = rectpuls(t,20e-3);subplot(211),plot(t,x1), axis([-0.1 0.1 -0.2 1.2])xlabel('Time (sec)');ylabel('Amplitude'); title('Triangular Aperiodic Pulse')subplot(212),plot(t,x2), axis([-0.1 0.1 -0.2 1.2])

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    15/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    15

    xlabel('Time (sec)');ylabel('Amplitude'); title('Rectangular Aperiodic Pulse')set(gcf,'Color',[1 1 1]),

    %%To generate a rectangular pulset=-5:0.01:5;pulse = rectpuls(t,2); %pulse of width 2 time unitsplot(t,pulse)axis([-5 5 -1 2]);grid

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    16/90

  • 8/10/2019 Basic Simulation Lab Manual (1)

    17/90

  • 8/10/2019 Basic Simulation Lab Manual (1)

    18/90

  • 8/10/2019 Basic Simulation Lab Manual (1)

    19/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    19

    % sincx = linspace(-5,5);y = sinc(x);subplot(1,2,1);plot(x,y)xlabel(time);ylabel(amplitude);title(sinc function);subplot(1,2,2);stem(x,y);xlabel(time);ylabel(amplitude);title(sinc function);

    CONCLUSION:In this experiment various signals have been generated UsingMATLAB

    Exersize questions:generate following signals using MATLAB

    1.x(t)=e-t2.x(t)= t 2 / 2

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    20/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    20

    3.generate rectangular pulse function

    4.generate signum sunction sinc(t)= 1 t > 0

    0 t=0-1 t

  • 8/10/2019 Basic Simulation Lab Manual (1)

    21/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    21

    EXP.NO: 3

    OPERATIONS ON SIGNALS AND SEQUENCES SUCH AS ADDITION,

    MULTIPLICATION, SCALING, SHIFTING, FOLDING,

    COMPUTATION OF ENERGY AND AVERAGE POWER

    Aim:To perform arithmetic operations different types of signals Using MATLAB

    Software.

    EQUIPMENTS:

    PC with windows (95/98/XP/NT/2000).

    MATLAB Software

    THEORY :

    Basic Operation on Signals:

    Time shifting: y(t)=x(t-T)The effect that a time shift has on the appearance of a signalIf T is a positive number, the time shifted signal, x (t -T ) gets shifted to the right,otherwise it gets shifted left.

    Signal Shifting and Delay:

    . Shifting : y(n)={x(n-k)} ; m=n-k; y=x;

    Time reversal: Y(t)=y(-t) Time reversal _ips the signal about t = 0 as seen inFigure 1.

    Signal Addition and Substraction :Addition: any two signals can be added to form a third signal,

    z (t) = x (t) + y (t)

    Signal Amplification/Attuation :

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    22/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    22

    Multiplication/Divition: of two signals, their product is also a signal.z (t) = x (t) y (t)

    folding: y(n)={x(-n)} ; y=fliplr(x); n=-fliplr(n);

    %plot the 2 Hz sine wave in the top panelt = [0:.01:1]; % independent (time) variableA = 8; % amplitude

    f1 = 2; % create a 2 Hz sine wave lasting 1 secs1 = A*sin(2*pi*f1*t);

    f2 = 6; % create a 4 Hz sine wave lasting 1 secs2 = A*sin(2*pi*f2*t);figuresubplot(4,1,1)plot(t, s1)title('1 Hz sine wave')ylabel('Amplitude')%plot the 4 Hz sine wave in the middle panelsubplot(4,1,2)plot(t, s2)title('2 Hz sine wave')ylabel('Amplitude')%plot the summed sine waves in the bottom panelsubplot(4,1,3)plot(t, s1+s2)title('Summed sine waves')ylabel('Amplitude')xlabel('Time (s)')xmult=s1.*s2;

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    23/90

  • 8/10/2019 Basic Simulation Lab Manual (1)

    24/90

  • 8/10/2019 Basic Simulation Lab Manual (1)

    25/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    25

    s3=s1/2;subplot(3,2,3)plot(s3);xlabel('t');ylabel('amplitude');subplot(3,2,4)stem(s1);xlabel('t');ylabel('amplitude');s2=2*s1;subplot(3,2,5)stem(s2);xlabel('t');ylabel('amplitude');

    s3=s1/2;subplot(3,2,6)stem(s3);xlabel('t');ylabel('amplitude');

    Excersize questions: Sketch the following questions using MATLAB

    1. x(t)= u(-t+1)

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    26/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    26

    2. x(t)=3r(t-1)3. x(t)=U(n+2-u(n-3)4. x(n)=x1(n)+x2(n)where x1(n)={1,3,2,1},x2(n)={1,-2,3,2}5.

    x(t)=r(t)-2r(t-1)+r(t-2)6.

    x(n)=2(n+2)-2(n-4), -5 n 5.7.

    X(n)={1,2,3,4,5,6,7,6,5,4,2,1} determine and plot the following sequencea. x1(n)=2x(n-5-3x(n+4))b. x2(n)=x(3-n)+x(n)x(n-2)

    CONCLUSION:Inthis experiment the various oprations on signals have beenperformedUsing MATLAB have been demonstrated.

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    27/90

  • 8/10/2019 Basic Simulation Lab Manual (1)

    28/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    28

    for i=1:9x1(i)=h(n);n=n-1;

    endsubplot(3,2,2)stem(t,x1);xlabel('time'); ylabel('amplitude');title('folded signal');z=h+x1subplot(3,2,3);stem(t,z);xlabel('time'); ylabel('amplitude');title('sum of two signal');subplot(3,2,4);

    stem(t,z/2);xlabel('time'); ylabel('amplitude');title('even signal');a=h-x1;subplot(3,2,5);stem(t,a);xlabel('time'); ylabel('amplitude');

    title('difference of two signal');subplot(3,2,6);stem(t,a/2);xlabel('time'); ylabel('amplitude');

    title('odd signal');

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    29/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    29

    ENERGY AND POWER SIGNAL:A signal can be categorized into energy signal or powersignal: An energy signalhas a finite energy, 0 < E < . In other words, energy signalshave values only in the limited time duration. For example, a signal having only onesquare pulse is energy signal. A signal that decays exponentially has finite energy, so, itis also an energy signal. The power of an energy signal is 0, because of dividing finiteenergy by infinite time (or length).

    On the contrary, the power signalis not limited in time. It always exists from beginning

    to end and it never ends. For example, sine wave in infinite length is power signal. Sincethe energy of a power signal is infinite, it has no meaning to us. Thus, we use power(energy per given time) for power signal, because the power of power signal is finite, 0

    x')ylabel('--> pdf')figure(2)plot(x,cum_Px);gridaxis([-3 3 0 1]);title(['Gaussian Probability Distribution Function for mu_x=0 and sigma_x=',num2str(sig_x)]);title('\ite^{\omega\tau} = cos(\omega\tau) + isin(\omega\tau)')

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    64/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    64

    xlabel('--> x')ylabel('--> PDF')

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    65/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    65

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    66/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    66

    EXP.NO: 14

    14. Sampling theorem verification

    Aim: To detect the edge for single observed image using sobel edge detection and cannyedge detection.

    EQUIPMENTS:

    PC with windows (95/98/XP/NT/2000).MATLAB SoftwareSampling Theorem:A bandlimited signal can be reconstructed exactly if it is sampled at a rate atleast twicethe maximum frequency component in it." Figure 1 shows a signal g(t) that isbandlimited.

    Figure 1: Spectrum of bandlimited signal g(t)

    The maximum frequency component of g(t) is fm. To recover the signal g(t) exactly from

    its samples it has to be sampled at a rate fs 2fm.The minimum required sampling rate fs = 2fm is called 'Nyquist rate

    Proof: Let g(t) be a bandlimited signal whose bandwidth is fm(wm = 2fm).

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    67/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    67

    Figure 2: (a) Original signal g(t) (b) Spectrum G(w)(t) is the sampling signal with fs = 1/T > 2fm.

    Figure 3: (a) sampling signal (t) ) (b) Spectrum (w)

    Let gs(t) be the sampled signal. Its Fourier Transform Gs(w) isgiven by

    Figure 4: (a) sampled signal gs(t) (b) Spectrum Gs(w)

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    68/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    68

    To recover the original signal G(w):1. Filter with a Gate function, H2wm(w) of width 2wmScale it by T.

    Figure 5: Recovery of signal by filtering with a fiter of width 2wm

    Aliasing{ Aliasing is a phenomenon where the high frequency components of the sampled signalinterfere with each other because of inadequate sampling ws < 2wm.

    Figure 6: Aliasing due to inadequate sampling

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    69/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    69

    Aliasing leads to distortion in recovered signal. This is thereason why sampling frequency should be atleast twice thebandwidth of the signal. Oversampling{ In practice signal are oversampled, where fs is signi_cantlyhigher than Nyquist rate to avoid aliasing.

    Figure 7: Oversampled signal-avoids aliasing

    t=-10:.01:10;T=4;fm=1/T;x=cos(2*pi*fm*t);subplot(2,2,1);plot(t,x);xlabel('time');ylabel('x(t)')

    title('continous time signal')grid;n1=-4:1:4

    fs1=1.6*fm;fs2=2*fm;fs3=8*fm;x1=cos(2*pi*fm/fs1*n1);subplot(2,2,2);stem(n1,x1);xlabel('time');ylabel('x(n)')title('discrete time signal with fs

  • 8/10/2019 Basic Simulation Lab Manual (1)

    70/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    70

    subplot(2,2,3);plot(n2,x2)

    grid;n3=-20:1:20;x3=cos(2*pi*fm/fs3*n3);subplot(2,2,4);stem(n3,x3);xlabel('time');ylabel('x(n)')

    title('discrete time signal with fs>2fm')hold on

    subplot(2,2,4);plot(n3,x3)

    grid;

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    71/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    71

    CONCLUSION:In this experimentthe sampling theorem have been verifiedusing MATLAB

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    72/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    72

    EXP.No:15

    REMOVAL OF NOISE BY AUTO CORRELATION/CROSS

    CORRELATION

    Aim: removal of noise by auto correlation/cross correlation

    EQUIPMENTS:

    PC with windows (95/98/XP/NT/2000).MATLAB Software

    Detection of a periodic signal masked by random noise is of greate importance .Thenoise signal encountered in practice is a signal with random amplitude variations. Asignal is uncorrelated with any periodic signal. If s(t) is a periodic signal and n(t) is anoise signal then

    T/2Lim 1/T S(t)n(t-T) dt=0 for all TT-- -T/2

    Qsn(T)= cross correlation function of s(t) and n(t) Then Qsn(T)=0

    Detection by Auto-Correlation:

    S(t)=Periodic Signal mixed with a noise signal n(t).Then f(t) is [s(t ) + n(t) ]Let Qff(T) =Auto Correlation Function of f(t)

    Qss(t) = Auto Correlation Function of S(t)Qnn(T) = Auto Correlation Function of n(t)

    T/2Qff(T)= Lim 1/T f(t)f(t-T) dt

    T-- -T/2

    T/2= Lim 1/T [s(t)+n(t)][s(t-T)+n(t-T)] dtT-- -T/2

    =Qss(T)+Qnn(T)+Qsn(T)+Qns(T)

    The periodic signal s(t) and noise signal n(t) are uncorrelatedQsn(t)=Qns(t)=0 ;Then Qff(t)=Qss(t)+Qnn(t)

    The Auto correlation function of a periodic signal is periodic of the same frequency andthe Auto correlation function of a non periodic signal is tends to zero for large value of Tsince s(t) is a periodic signal and n(t) is non periodic signal so Qss(T) is a periodic where

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    73/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    73

    as aQnn(T) becomes small for large values of T Therefore for sufficiently large values ofT Qff(T) is equal to Qss(T).

    Detection by Cross Correlation:

    f(t)=s(t)+n(t)

    c(t)=Locally generated signal with same frequencyas that of S(t)

    T/2Qfc (t) = Lim 1/T [s(t)+n(t)] [ c(t-T)] dt

    T-- -T/2

    = Qsc(T)+Qnc(T)

    C(t) is periodic function and uncorrelated with the random noise signal n(t). HenceQnc(T0=0) Therefore Qfc(T)=Qsc(T)

    a)auto correlationclear allclct=0:0.1:pi*4;s=sin(t);k=2;subplot(6,1,1)plot(s);title('signal s');xlabel('t');ylabel('amplitude');n = randn([1 126]);f=s+n;subplot(6,1,2)plot(f);title('signal f=s+n');xlabel('t');

    ylabel('amplitude');as=xcorr(s,s);subplot(6,1,3)plot(as);title('auto correlation of s');xlabel('t');ylabel('amplitude');an=xcorr(n,n);subplot(6,1,4)plot(an);

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    74/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    74

    title('auto correlation of n');xlabel('t');ylabel('amplitude');cff=xcorr(f,f);subplot(6,1,5)plot(cff);title('auto correlation of f');xlabel('t');ylabel('amplitude');hh=as+an;subplot(6,1,6)plot(hh);title('addition of as+an');xlabel('t');

    ylabel('amplitude');

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    75/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    75

    B)CROSS CORRELATION :

    clear allclct=0:0.1:pi*4;s=sin(t);k=2;%sk=sin(t+k);

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    76/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    76

    subplot(7,1,1)plot(s);title('signal s');xlabel('t');ylabel('amplitude');c=cos(t);subplot(7,1,2)plot(c);title('signal c');xlabel('t');ylabel('amplitude');n = randn([1 126]);f=s+n;subplot(7,1,3)plot(f);title('signal f=s+n');xlabel('t');ylabel('amplitude');asc=xcorr(s,c);subplot(7,1,4)

    plot(asc);title('auto correlation of s and c');xlabel('t');ylabel('amplitude');anc=xcorr(n,c);subplot(7,1,5)plot(anc);title('auto correlation of n and c');xlabel('t');ylabel('amplitude');cfc=xcorr(f,c);subplot(7,1,6)plot(cfc);title('auto correlation of f and c');xlabel('t');ylabel('amplitude');hh=asc+anc;

    subplot(7,1,7)plot(hh);title('addition of asc+anc');xlabel('t');ylabel('amplitude');

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    77/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    77

    CONCLUSION:in this experiment the removal of noise by autocorrelation/cross correlationhave been verified using MATLAB

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    78/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    78

    EXP.No:16

    EXTRACTION OF PERIODIC SIGNAL MASKED BY NOISE USING

    CORRELATION

    Extraction Of Periodic Signal Masked By Noise Using Correlation

    clear all;

    close all;

    clc;

    n=256;

    k1=0:n-1;

    x=cos(32*pi*k1/n)+sin(48*pi*k1/n);

    plot(k1,x)

    %Module to find period of input signl

    k=2;

    xm=zeros(k,1);

    ym=zeros(k,1);

    hold on

    for i=1:k

    [xm(i) ym(i)]=ginput(1);

    plot(xm(i), ym(i),'r*');

    end

    period=abs(xm(2)-xm(1));

    rounded_p=round(period);

    m=rounded_p

    % Adding noise and plotting noisy signal

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    79/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    79

    y=x+randn(1,n);

    figure

    plot(k1,y)

    % To generate impulse train with the period as that of input signal

    d=zeros(1,n);

    for i=1:n

    if (rem(i-1,m)==0)

    d(i)=1;

    end

    end

    %Correlating noisy signal and impulse train

    cir=cxcorr1(y,d);

    %plotting the original and reconstructed signal

    m1=0:n/4;

    figure

    plot(m1,x(m1+1),'r',m1,m*cir(m1+1));

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    80/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    80

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    81/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    81

    Application

    The theorem is useful for analyzing linear time-invariant systems, LTI systems, when theinputs and outputs are not square integrable, so their Fourier transforms do not exist. Acorollary is that the Fourier transform of the autocorrelation function of the output of anLTI system is equal to the product of the Fourier transform of the autocorrelationfunction of the input of the system times the squared magnitude of the Fourier transform

    of the system impulse response. This works even when the Fourier transforms of theinput and output signals do not exist because these signals are not square integrable, sothe system inputs and outputs cannot be directly related by the Fourier transform of theimpulse response. Since the Fourier transform of the autocorrelation function of a signalis the power spectrum of the signal, this corollary is equivalent to saying that the powerspectrum of the output is equal to the power spectrum of the input times the powertransfer function.

    This corollary is used in the parametric method for power spectrum estimation.

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    82/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    82

    CONCLUSION:In this experimentthe Weiner-Khinchine Relation have beenverified using MATLAB.

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    83/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    83

    EXP.No:17

    VERIFICATION OF WIENERKHINCHIN RELATION

    AIM: Verification of wienerkhinchine relation

    EQUIPMENTS:

    PC with windows (95/98/XP/NT/2000).MATLAB Software

    The WienerKhinchin theorem(also known as the WienerKhintchine theoremand

    sometimes as the WienerKhinchinEinstein theoremor the KhinchinKolmogorovtheorem) states that the power spectral densityof a wide-sense-stationary randomprocessis the Fourier transformof the corresponding autocorrelationfunction.[1][2][3]

    Continuous case:

    Where

    is the autocorrelation function defined in terms of statistical expectation, and where is thepower spectral density of the function . Note that the autocorrelation function is definedin terms of the expected value of a product, and that the Fourier transform of does notexist in general, because stationary random functions are not square integrable.

    The asterisk denotes complex conjugate, and can be omitted if the random process is real-valued.

    Discrete case:

    Where

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    84/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    84

    and where is the power spectral density of the function with discrete values . Being asampled and discrete-time sequence, the spectral density is periodic in the frequencydomain.

    PROGRAM:

    clcclear all;t=0:0.1:2*pi;x=sin(2*t);subplot(3,2,1);plot(x);au=xcorr(x,x);subplot(3,2,2);

    plot(au);v=fft(au);subplot(3,2,3);plot(abs(v));fw=fft(x);subplot(3,2,4);plot(fw);fw2=(abs(fw)).^2;subplot(3,2,5);plot(fw2);

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    85/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    85

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    86/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    86

    EXP18.

    CHECKING A RANDOM PROCESS FOR STATIONARITY INWIDE SENSE.

    AIM: Checking a random process for stationarity in wide sense.

    EQUIPMENTS:

    PC with windows (95/98/XP/NT/2000).MATLAB Software

    Theory:a stationary process(or strict(ly) stationary processor strong(ly) stationary process)

    is a stochastic process whose joint probability distribution does not change when shiftedin time or space. As a result, parameters such as the mean and variance, if they exist, alsodo not change over time or position..

    Definition

    Formally, letXtbe a stochastic process and let represent thecumulative distribution function of the joint distribution ofXtat times t1..tk. Then,Xt

    is said to be stationary if, for all k, for all , and for all t1..tk

    Weak or wide-sense stationarity

    A weaker form of stationarity commonly employed in signal processing is known asweak-sense stationarity, wide-sense stationarity(WSS) or covariance stationarity.

    WSS random processes only require that 1st and 2nd moments do not vary with respectto time. Any strictly stationary process which has a mean and a covariance is also WSS.

    So, a continuous-time random processx(t) which is WSS has the following restrictions onits mean function

    and autocorrelation function

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    87/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    87

    The first property implies that the mean function mx(t) must be constant. The secondproperty implies that the correlation function depends only on the differencebetween t1

    and t2and only needs to be indexed by one variable rather than two variables. Thus,instead of writing,

    we usually abbreviate the notation and write

    This also implies that the autocovariance depends only on = t1 t2, since

    When processing WSS random signals with linear, time-invariant (LTI) filters, it ishelpful to think of the correlation function as a linear operator. Since it is a circulantoperator (depends only on the difference between the two arguments), its eigenfunctionsare the Fourier complex exponentials. Additionally, since the eigenfunctions of LTI

    operators are also complex exponentials, LTI processing of WSS random signals ishighly tractableall computations can be performed in the frequency domain. Thus, theWSS assumption is widely employed in signal processing algorithms.

    Applicatons: Stationarity is used as a tool in time series analysis, where the raw dataare often transformed to become stationary, for example, economic data are oftenseasonal and/or dependent on the price level. Processes are described as trend stationaryif they are a linear combination of a stationary process and one or more processesexhibiting a trend. Transforming these data to leave a stationary data set for analysis isreferred to as de-trending

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    88/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    88

    Stationary and Non Stationary Random Process:

    A random X(t) is stationary if its statistical properties are unchanged by a time shift in thetime origin.When the auto-Correlation function Rx(t,t+T) of the random X(t) varies withtime difference T and the mean value of the random variable X(t1) is independent of thechoice of t1,then X(t) is said to be stationary in the wide-sense or wide-sense stationary .So a continous- Time random process X(t) which is WSS has the following properties

    1) E[X(t)]=X(t)= X(t+T)

    2) The Autocorrelation function is written as a function of T that is

    3) RX(t,t+T)=Rx(T)

    If the statistical properties like mean value or moments depends on time then therandom process is said to be non-stationary.When dealing wih two random process X(t) and Y(t), we say that they are jointly

    wide-sense stationary if each pocess is stationary in the wide-sense.

    Rxy(t,t+T)=E[X(t)Y(t+T)]=Rxy(T).

    MATLAB PROGRAM:

    clear allclcy = randn([1 40])my=round(mean(y));z=randn([1 40])mz=round(mean(z));vy=round(var(y));vz=round(var(z));t = sym('t','real');h0=3;x=y.*sin(h0*t)+z.*cos(h0*t);

    mx=round(mean(x));k=2;

    xk=y.*sin(h0*(t+k))+z.*cos(h0*(t+k));x1=sin(h0*t)*sin(h0*(t+k));x2=cos(h0*t)*cos(h0*(t+k));c=vy*x1+vz*x1;%if we solve "c=2*sin(3*t)*sin(3*t+6)" we get c=2cos(6)%which is a costant does not depent on variable 't'% so it is wide sence stationary

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    89/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    89

    VIVA-VOICE:

    1. Define Signal2.

    Define determistic and Random Signal3.

    Define Delta Function4.

    What is Signal Modeling5. Define Periodic and a periodic Signal6. Define Symetric and Anti-Symmetric Signals7. Define Continuous and Discrete Time Signals8. What are the Different types of representation of discrete time signals9.

    What are the Different types of Operation performed on signals10.What is System11.What is Causal Signal12.What are the Different types of Systems

    13.

    What is Linear System14.

    What is Signum function?15.

    What is Static and Dynamic System16.What is Even Signal17.What is Odd Signal18.Define the Properties of Impulse Signal19.What is Causality Condition of the Signal20.

    What is Condition for System Stability21.Define Convolution22.Define Properties of Convolution23.What is the Sufficient condition for the existence of F.T

    24.

    Define the F.T of a signal25.State Paesevals energy theorem for a periodic signal26.

    Define sampling Theorem27.What is Aliasing Effect28.what is Under sampling29.What is Over sampling30.Define Correlation31.

    Define Auto-Correlation32.Define Cross-Correlation33.Define Convolution34.Define Properties of Convolution

    35.

    What is the Difference Between Convolution& Correlation36.What are Dirchlet Condition37.

    Define Fourier Series38.What is Half Wave Symmetry39.What are the properties of Continuous-Time Fourier Series40.Define Laplace-Transform41.What is the Condition for Convergence of the L.T42.What is the Region of Convergence(ROC)43.

    State the Shifting property of L.T44.State convolution Property of L.T

    w.jntuworld.com

    www.jntuworld.com

    www.jwjobs.net

  • 8/10/2019 Basic Simulation Lab Manual (1)

    90/90

    RRS College of Engineering and TechnologyDepartment of Electronics and Communication Engineering

    Basic Simulation Lab Manual

    45.Define Transfer Function46.Define Pole-Zeros of the Transfer Function47.What is the Relationship between L.T & F.T &Z.T48.

    Fined the Z.T of a Impulse and step49.

    What are the Different Methods of evaluating inverse z-T50.

    Explain Time-Shifting property of a Z.T51.what are the ROC properties of a Z.T52.Define Initial Value Theorem of a Z.T53.Define Final Value Theorem of a Z.T54.Define Sampling Theorem55.

    Define Nyquist Rate56.Define Energy of a Signal57.Define Power of a signal58.Define Gibbs Phenomena

    59.

    Define the condition for distortionless transmission through the system60.

    What is signal band width61.

    What is system band width62.What is Paley-Winer criterion?63.Derive relationship between rise time and band width.64.State the relation ship between PSD and ACF?65.What is the integration of ramp signal?66.

    Difference between vectors and signals?67.What is the important of dot product over cross product in signals?68.Define Hilbert transform?69.Relation ship between FT and ZT?

    70.

    What are the different properties of signals?71.What are the different properties of systems?72.

    what LTI system?73.What is time variant and time in variant with examples?74.Define inevitability?75.Define stable and un stable?76.what is the condition for WSS random process?77.

    Define random variable with examples?78.Define random process with examples?79.Difference between ACF and CCF?80.what are the different noises?

    w.jntuworld.com www.jwjobs.net