sp lab report

Upload: prince-sen

Post on 06-Apr-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 Sp Lab Report

    1/50

    1

    A

    LAB REPORT

    ON

    SIGNAL PROCESSING

    Submitted as a requirement for the partial fulfillment of

    Bachelors Degree From

    Rajasthan Technical University, Kota

    SUBMITTED BY

    SURYA PRAKASH

    Final year ECE

    M.L.V.Textile and engineering College.

    ( An Autonomous Engineering College of Govt. Of Rajasthan)

    Bhilwara, Rajasthan

  • 8/3/2019 Sp Lab Report

    2/50

    2

    ACKNOWLEDGMENT

    First and foremost, we would like to express my sincere gratitude to our lab in

    charge Mrs. Sarita Chauhan . We were privileged to experience a sustained

    enthusiastic and involved interest from her side. This fueled our enthusiasm even

    further and encouraged us to boldly step into what was a totally dark and

    unexplored expanse before us. We also like to thank the MLVTEC staff members

    and the institute, in general, for extending a helping hand at every juncture of need.

    Keerti vyas

    Yogesh kumar

  • 8/3/2019 Sp Lab Report

    3/50

    3

    INDEX

    Object Page no.

    1. Introduction to MATLAB..5

    2. Explain following with example....6

    3. Explain commands with example.9

    4. Write a program (WAP) for adding five numbers at run time.14

    5. WAP checking whether a number is prime or not

    (i) Using function.15

    (ii) Without using function...15

    6. WAP to find a number is divisible by 2 or 3 or both...16

    7. WAP to find factorial of a given number.17

    8. WAP to perform convolution...18

    9. WAP to plot sine and cosine functions

    (i) On same Window.19

    (ii) On different Window..20

    10. WAP to add two sine functions..21

    11. WAP to perform folding of a sequence..22

    12. WAP to plot Gaussian curve...23

    13. WAP to plot Rayleigh probability curve24

    14. WAP to design bode plot25

    15. WAP to perform auto correlation and cross correlation26

    16. WAP to compare the order of butterworth filter..28

  • 8/3/2019 Sp Lab Report

    4/50

    4

    17. WAP to compare the 4th

    order butterworth filter for frequency

    w=100 and w=200...29

    18. WAP to plot the following function on different window...........................33

    a) Unit step

    b) Ramp function

    c) Unit impulse

    19. WAP to plot the following function on same window36

    a) Unit step

    b) Ramp function

    c) Unit impulse

    20. WAP to generate the impulse sequence at no. sample laying between

    n1

  • 8/3/2019 Sp Lab Report

    5/50

    5

    EXPERIMENT NO 1

    Object- Write the introduction to MATLAB.

    Theory:

    MATLAB is a powerful computing system for handling scientific and engineering calculations.The name MATLAB stands for Matrix Laboratory, because the system was designed to make

    matrix computations particularly easy. It intended to provide easy access to the matrix libraries

    developed by Linpack and Eispack projects. These are carefully tested high quality programming

    packages for solving linear equations and eigen value problems.

    OR,

    MATLAB

    is a high-level technical computing language and interactive environment for

    algorithm development, data visualization, data analysis, and numerical computation. Using

    MATLAB, you can solve technical computing problems faster than with traditional programming

    languages, such as C, C++, and Fortran.

    You can use MATLAB in a wide range of applications, including signal and image processing,

    communications, control design, test and measurement, financial modeling and analysis, and

    computational biology. Add-on toolboxes (collections of special-purpose MATLAB functions)

    extend the MATLAB environment to solve particular classes of problems in these application

    areas.

    MATLAB provides a number of features for documenting and sharing your work. You can

    integrate your MATLAB code with other languages and applications, and distribute your

    MATLAB algorithms and applications.

    MATLAB is originally written in FORTRAN developed by Cleve Moler, the chairman of computer

    science department at the university of new mexico, started developing MATLAB in 1970s.

    Key Features

    y High-level language for technical computing

    y Development environment for managing code, files, and data

    y Interactive tools for iterative exploration, design, and problem solving

    y Mathematical functions for linear algebra, statistics, Fourier analysis, filtering, optimization, andnumerical integration

    y 2-D and 3-D graphics functions for visualizing data

    y Tools for building custom graphical user interfaces

    y Functions for integrating MATLAB based algorithms with external applications and languages,

    such as C, C++, Fortran, Java, COM, and MicrosoftExcel.

  • 8/3/2019 Sp Lab Report

    6/50

    6

    EXPERIMENT NO 2

    Object- Explain the following with suitable examples.

    (i) For loop

    (ii) If-else

    (iii) Switch case

    Theory :

    (i) For Loop :

    for loops are often used when a sequence of operations is to be performed a predetermined

    number of times. For example computing the average of a list of numbers requires adding up a

    known number of values.Syntax

    Loop counter incremented by one:

    for i = start value : end valuex = ...y = ......end

    i is the loop counter. On the first pass through the loop, i is set to start value. On the second

    pass through the loop i is set to start Value+1. The Matlab statements between the for and the

    end are evaluated until i>end value.

    Example:Compute the sum of the _rst n integers

    n = 10;s = 0;for i=1:ns = s + i;end

    (ii) If-else :

    Syntax :

    ifexpression

    statementselseifexpression

    statements

    else

    statements

    end

  • 8/3/2019 Sp Lab Report

    7/50

    7

    Description :

    ifexpression, statements, end evaluates an expression, and executes a group of statements

    when the expression is true.

    Else-if and else are optional, and execute statements only when previous expressions in

    the if block are false. An if block can include multiple else-if statements.

    An evaluated expression is true when the result is nonempty and contains all nonzero elements

    (logical or real numeric). Otherwise, the expression is false.

    Expressions can include relational operators (such as < or ==) and logical operators (such

    as &&, ||, or ~). MATLAB evaluates compound expressions from left to right, adhering

    to operator precedence rules.

    Examples :

    x=-5:0.1:5for i=1:101

    if x(i)>=0y(i)=1else

    y(i)=0end

    endstem(x,y)

    (iii) Switch case:

    Syntax

    switch switch_expression

    case case_expressionstatements

    case case_expression

    statements

    :

    otherwise

    statements

    end

    Description

    A switch block conditionally executes one set of statements from several choices. Each choice isa case.

    An evaluated switch_expression is a scalar or string. An evaluated case_expression is a scalar, a

    string, or a cell array of scalars or strings. The switch block tests each case until one of the cases

    is true. A case is true when:

    For numbers, eq(case_expression,switch_expression).

    For strings, strcmp(case_expression,switch_expression).

    For objects that support the eq function, eq(case_expression,switch_expression).

  • 8/3/2019 Sp Lab Report

    8/50

  • 8/3/2019 Sp Lab Report

    9/50

    9

    EXPERIMENT NO 3

    Object- Explain the following commands with example.

    a) whos e) zeros

    b) sum f) ones

    c) diag g) eyes

    d) magic h) randn

    a) whos : whos lists current variable, long form. It lists all the variables in the current

    workspace , together with information about their size, shape, bytes, class.

    Example:

    b) sum :

    y B= sum(A) returns sum along different dimensions of array. If a is floating point,

    that is double or single.

    y If A is a vector, sum(A) returns the sum of elements.

    y If a is a matrix, sum(A) treats the column of A as vectors, returning a row vector

    of the sum of each column.

  • 8/3/2019 Sp Lab Report

    10/50

    10

    Example :

    C)Diag:

    Syntax :

    x=diag(v,k)

    x=diag(v)

    Description : x=diag(v,k) where v is the vector of n components, returns a square matrix x of

    order n+abs(k), k=0 represents the main diagonal, k>0 above the main diagonal, and k

  • 8/3/2019 Sp Lab Report

    11/50

    11

    Example :

    c) Magic:

    Syntax: m=magic(n)

    Description: m=magic(n) returns an nxn matrix constructed from the integers 1 through n2

    with equal row and column sums. The order n must be a scalar

    Example:

  • 8/3/2019 Sp Lab Report

    12/50

    12

    d) Zeros :

    Syntax : zeros(n) or zeros (m,n)

    Description :

    y It defines a matrix of order with all entries zero.

    y

    An error message will appear if n is not a scalar.

    Example :

    e) Ones :

    Syntax : ones(n) or ones(m,n)

    Description: it will generate a matrix with all entries o1. Where n must be a scalar.

    Example:

    f) Eyes:

    Syntax : eye(n)

    Description :

    y It will generate a identity matrix of order nxn.

    y The argument n must be scalar and it represents the order of square matrix.

  • 8/3/2019 Sp Lab Report

    13/50

    13

    Example:

    g) randn :

    Syntax : randn(n) or randn(m,n)

    Description :

    y Normally distributed pseudorandom numbers.

    y A=randn(n), returns a matrix containing pseudorandom values drawn from the

    standard normal distribution.

    Example :

  • 8/3/2019 Sp Lab Report

    14/50

    14

    EXPERIMENT NO 4

    Object- Write a program for addition of five numbers at run time.

    Program :

    sum=0;for i=1:5

    u=input('enter ur number');sum=sum+u ;

    enddisp('sum of number =');disp(sum);

    Output:

  • 8/3/2019 Sp Lab Report

    15/50

    15

    EXPERIMENT NO 5

    Object- Write a program for checking whether a number is prime or not with and without using

    function isprime.

    Program :

    (i) Using function isprime

    u=input(Enter your number);x=isprime(u);if x==1

    disp(number is prime);else

    disp(number is not prime);

    (ii) Without using isprime

    v=0;s=1;u=input('enter ur num');for i=2:u-1

    s=rem(u,i);if s==0

    disp('Number is not prime');break;

    endendif s~=0

    v=1;disp('no is prime');

    end

    Output :

  • 8/3/2019 Sp Lab Report

    16/50

    16

    EXPERIMENT NO 6

    Object- Write a program to find the number divisible by 2 or 3 or both.

    Program :

    u=input('enter ur num');a=rem(u,2);if a==0

    disp('num is divisible by 2');endb=rem(u,3);if b==0

    disp('num is divisible by 3');endc=rem(u,6);if c==0

    disp('num is div

    isible by both 2 and 3');end

    Output:

  • 8/3/2019 Sp Lab Report

    17/50

    17

    EXPERIMENT NO 7

    Object- Write a program to find factorial of a given number.

    Program :

    u=input('Enter your number');s=1;for i=1:u

    s=s*i;enddisp('factorial of a given number is');disp(s);

    Output :

  • 8/3/2019 Sp Lab Report

    18/50

    18

    EXPERIMENT NO 8

    Object- Write a program to perform convolution.

    Program :

    u=input('Enter first sequence');h=input('Enter second sequence');subplot(3,1,1);stem(u);title('First input sequence');subplot(3,1,2);stem(h);title('Second input sequence');

    subplot(3,1,3);y=conv(u,h);stem(y)title('convolution sequence');

    Output :

  • 8/3/2019 Sp Lab Report

    19/50

    19

    EXPERIMENT NO 9

    Object- Write a program to plot sine and cosine function on same and different window.

    Program :

    (i) On same window

    x=0:0.01:4*pi;y=sin(x);z=cos(x);subplot(2,1,1);plot(y);xlabel('x-axis');ylabel('y-axis');

    title('sine Function');subplot(2,1,2)plot(z);xlabel('x-axis');ylabel('y-axis');

    Output :

  • 8/3/2019 Sp Lab Report

    20/50

    20

    (ii) On differentWindow

    x=0:0.01:4*pi;y=sin(x);z=cos(x);figure(1)plot(y);xlabel('x-axis');ylabel('y-axis');title('sine Function');figure(2)plot(z);xlabel('x-axis');title('cosine Function');ylabel('y-axis');

    Output :

  • 8/3/2019 Sp Lab Report

    21/50

    21

    EXPERIMENT NO 10

    Object- Write a program for addition of two sine functions.

    Program :

    t1=0:.01:2*pi;t2=0:.01:2*pi;y=sin(t1);z=sin(t2);u=y+z;subplot(3,1,1);plot(y);title('First Sine function');subplot(3,1,2);plot(z);title('second Sine function');

    subplot(3,1,3);plot(u);title('Addition');

    Output:

  • 8/3/2019 Sp Lab Report

    22/50

    22

    EXPERIMENT NO 11

    Object- Write a program for folding of original sequence.

    Program :

    x=input('enter original sequence=');y=fliplr(x);subplot(2,1,1);stem(x);xlabel('x-axis');ylabel('amplitude');title('Original sequence');subplot(2,1,2);stem(y);xlabel('x-axis');ylabel('amplitude');

    title('Folded sequence');

    Input: [1 23456]

    Output:

  • 8/3/2019 Sp Lab Report

    23/50

    23

    EXPERIMENT NO 12

    Object- Write a program to plot Guassian Curve.

    Program :

    x=0:0.1:10;y=gaussmf(x,[2,5]);plot(x,y);title('guassian curve');

    Output :

  • 8/3/2019 Sp Lab Report

    24/50

    24

    EXPERIMENT NO 13

    Object- Write a program to plot Rayleigh Probability Curve.

    Program :

    x=0:.1:3;p=raylpdf(x,1);plot(x,p);title('rayleigh probability curve');

    OUTPUT :

  • 8/3/2019 Sp Lab Report

    25/50

    25

    EXPERIMENT NO 14

    Object- Write a program to design Bode plot for a function.

    Program :

    g=(s^2+0.1*s+7.5)/((s^4)+0.12*s^3+9*s^2);h=tf([1 0.1 7.5],[1 0.12 9 0 0]);bode(h);grid on;

    OUTPUT :

  • 8/3/2019 Sp Lab Report

    26/50

    26

    EXPERIMENT NO 15

    Object- Write a program auto-correlation and cross correlation.

    Program :

    Auto-correlation

    x=input('enter the sequence=');y=xcorr(x,x);figure(1);subplot(2,1,1);stem(x);xlabel('x-axis');ylabel('amplitude');

    title('input');subplot(2,1,2);stem(fliplr(y));xlabel('x-axis');ylabel('amplitude');title('Output');disp('the resultant signal is');

    Input : [1 234]

    Output:

  • 8/3/2019 Sp Lab Report

    27/50

    27

    (2)Cross-Correlation

    x=input('enter the first sequence=');h=input('enter the second sequence=');

    y=xcorr(x,h);figure(1);subplot(3,1,1);stem(x);title('first Input');xlabel('n-->');ylabel('amplitude');subplot(3,1,2);stem(h);xlabel('n-->');ylabel('amplitude');title('Second Input');subplot(3,1,3);stem(fliplr(y));xlabel('n-->');ylabel('amplitude');title('Output');disp('the resultant signal is');

    Given Inputs: [1 234] and [423 1]

    Output:

  • 8/3/2019 Sp Lab Report

    28/50

    28

    EXPERIMENT NO 16

    Object- Write a program to compare the order of butterworth filter.

    Program :

    s=tf('s');w=100;g=((w^5)/((s+w)*((s*s)+(0.765*w*s)+(w*w))*((s*s)+(1.85*s*w)+(w*w))));bode(g);grid on;title('Fifth Order Butterworth Filter');h=((w^4)/(((s*s)+(0.765*w*s)+(w*w))*((s*s)+(1.85*s*w)+(w*w))));figure(2);bode(h);grid on;title('Fourth Order Butterworth Filter');

    k=((w^3)/((s+w)*((s*s)+(w*s)+(w*w))));figure(3);bode(k);grid on;title('Third Order Butterworth Filter');u=((w^2)/(((s*s)+(sqrt(2)*w*s)+(w*w))));figure(4);bode(u);grid on;title('Second Order Butterworth Filter');

  • 8/3/2019 Sp Lab Report

    29/50

  • 8/3/2019 Sp Lab Report

    30/50

    30

  • 8/3/2019 Sp Lab Report

    31/50

    31

    Experiment No- 17Object - To compare the 4th order butterworth filter for frequency w=100 and w=200.

    Program :

    s=tf('s');w=100;h=((w^4)/((s*s)+(0.765*w*s)+(w*w)*((s*s)+(1.85*s*w)+(w*w))));figure(1);bode(h);grid on;title('fourth order butterworth filter for w=100');W=200;g=((w^4)/((s*s)+(0.765*w*s)+(w*w)*((s*s)+(1.85*s*w)+(w*w))));figure(2);bode(g);

    grid on;title('fourth order butterworth filter for w= 200');

    output:

  • 8/3/2019 Sp Lab Report

    32/50

    32

  • 8/3/2019 Sp Lab Report

    33/50

    33

    EXPERIMENT NO 18

    Object-Write a program to plot the following function on different window.

    d) Unit step b) Ramp function c) Unit impulse

    Program :

    a) Unit step

    x=-5:0.1:5for i=1:101

    if x(i)>=0y(i)=1else

    y(i)=0end

    endstem(x,y)xlabel('x-axis')ylabel('y-axis')

    axis([-5,5,-5,5])title('Unit step response')

    Output:

  • 8/3/2019 Sp Lab Report

    34/50

    34

    b) Ramp Function

    x=-5:0.1:5for i=1:101

    if x(i)>=0

    y(i)=

    x(i)else

    y(i)=0end

    endstem(x,y)xlabel('x-axis')ylabel('y-axis')

    axis([-5,5,-5,5])title('Comtinuous Ramp signal')

    Output:

  • 8/3/2019 Sp Lab Report

    35/50

    35

    c) Unit Impulse

    x=-5:0.1:5for i=1:101

    if x(i)==0

    y(i)=1;else

    y(i)=0;end

    endstem(x,y)xlabel('x-axis')ylabel('y-axis')

    axis([-5,5,-5,5])title('unit Impulse response')

    Output:

  • 8/3/2019 Sp Lab Report

    36/50

    36

    EXPERIMENT NO 19

    Object- Write a program to plot the following function on same window.

    a) Unit step b) Ramp function c) Unit impulse

    Program :

    x=-5:0.1:5for i=1:101

    if x(i)>=0y(i)=1else

    y(i)=0end

    endsubplot(2,2,1)

    plot(x,y)xlabel('x-axis')ylabel('y-axis')

    axis([-5,5,-5,5])title('Unit step response')for i=1:101

    if x(i)>=0y(i)=x(i)else

    y(i)=0end

    end

    subplot(2,2,2)plot(x,y)

    xlabel('x-axis')ylabel('y-axis')

    axis([-5,5,-5,5])title('Comtinuous Ramp signal')for i=1:101

    if x(i)==0y(i)=1;

    elsey(i)=0;

    endendsubplot(2,2,3)plot(x,y)xlabel('x-axis')ylabel('y-axis')

    axis([-5,5,-5,5])title('unit Impulse response')

  • 8/3/2019 Sp Lab Report

    37/50

    37

  • 8/3/2019 Sp Lab Report

    38/50

    38

    EXPERIMENT-20

    Object-write a program to generate the impulse sequence at no. sample layingbetween n1

  • 8/3/2019 Sp Lab Report

    39/50

    39

    EXPERIMENT NO 21

    Object- Draw a signal and apply following properties on it

    b) Shifting b) Scaling c) Inverse

    Program :

    x=1:0.01:4*pi;y=sin(x);figure(1);plot(y);title('Original sequence')p=x-2;

    z=sin(p);figure(2);plot(z);title('Shifted sequence')q=2*x;y=sin(q);figure(3);plot(y);title('Scaling');p=-x;z=sin(p);figure(4);plot(z);

    title('inverse');

    Output:

  • 8/3/2019 Sp Lab Report

    40/50

    40

    Experiment No- 22

    Object: write a program to perform

    X= an

    * u*(n)

    Program:

    ns=input('enter the strating point of the sequence=');ne=input('enter the ending point of the sequence=')'a=input('the value of a=');n=[ns:ne];u=[(n-ns)>=0];subplot(2,2,1);stem(n,u);title('unit signal u(n)');xlabel('Samples n');ylabel('u(n)');e=a*exp(n);

    subplot(2,2,2);stem(n,e);title('exponential signal e=(a^n)');xlabel('Samples n')ylabel('e=(a^n)');m=u.*e;subplot(2,2,3);stem(n,m);title('multiplied signal m=u*e');xlabel('Samples n');ylabel('m=a*exp(n).*u');

    output:

  • 8/3/2019 Sp Lab Report

    41/50

    41

    EXPERIMENT -23

    Object : write a program to generate complex exponential function

    X = exp (complex(sigma,w)*n) ; sigma=0.3,w= 0.2

    Program:

    sigma=input('enter the value of sigma=');w=input('enter the value of w=');n=[1:100];x=exp(complex(sigma,w)*n);stem(n,x);title('generating the exponential sequence for sigma and omega');xlabel('samples n');ylabel('amplitude of x(n)');pause;

    clc;clear all;close all;

    output:

  • 8/3/2019 Sp Lab Report

    42/50

    42

    EXPERIMENT-24

    Object: write a program to design finite impulse response filter (low pass) for fc=0.6 & N=20.

    Program:

    fc=0.6;N=20;hf=fdesign.lowpass('N,fc',N,fc);hd(1)=design(hf,'window','window',@hamming);hd(2)=design(hf,'window','window',{@chebwin,50});hfvt=fvtool(hd);legend(hfvt,'hamming window design','dolph chebyshev window design');

    output:

    0 0.1 0 .2 0 .3 0 .4 0 .5 0.6 0.7 0.8 0.9

    -7 0

    -6 0

    -5 0

    -4 0

    -3 0

    -2 0

    -1 0

    0

    Normalized Frequency (vT rad/sample)

    M

    agnitu

    de

    (dB)

    Magnitude Response (dB)

    hamming window des ign

    do lph chebyshev w indow des ign

  • 8/3/2019 Sp Lab Report

    43/50

    43

    EXPERIMENT-25

    Object: write a program to design kaiser window design

    Fp=0.6, fst=0.7725, Ap=0.01, Ast=90

    Program:

    fc=0.6;n=20;hf=fdesign.lowpass('n,fc',n,fc);fp=0.6;fst=0.7725;ap=0.01;ast=90;setspecs(hf,'fp,fst,ap,ast',fp,fst,ap,ast);hd(4)=design(hf,'kaiserwin');hfvt=fvtool(hd(4));

    output:

    0 0.1 0 .2 0 .3 0 .4 0 .5 0.6 0.7 0.8 0.9

    -100

    -8 0

    -6 0

    -4 0

    -2 0

    0

    Normalized Frequency (vT rad/sample)

    M

    agnitude(d

    B)

    Magnitude Response (dB)

  • 8/3/2019 Sp Lab Report

    44/50

    44

    EXPERIMENT-26

    Object: write a program to perform equiripple technique to optimize Kaiser window solution.

    Program:

    fc=0.6;N=20;hf=fdesign.lowpass('N,fc',N,fc);fp=0.6;fst=0.7725;ap=0.01;ast=90;setspecs(hf,'fp,fst,ap,ast',fp,fst,ap,ast);hd(4)=design(hf,'kaiserwin');

    hfv

    t=fv

    tool(hd(4));hd(5)=design(hf,'equiripple');hfvt=fvtool(hd(4:5));legend(hfvt,'kaiser window design,filter order 68','equirippledesign,filter order 53');

    output:

    0 0.1 0 .2 0 .3 0 .4 0 .5 0.6 0.7 0.8 0.9

    -100

    -8 0

    -6 0

    -4 0

    -2 0

    0

    Normalized Frequency (vT rad/sample)

    M

    agnitude

    (dB)

    Magnitude Response (dB)

    kaiser w indow des ign,f i lter order 68

    equiripple des ign,fi lter order 53

  • 8/3/2019 Sp Lab Report

    45/50

    45

    Experiment No- 27

    Object: write a program to filter order control

    N=20

    Percentage order =100 to 101Coefficients setspecs(hf, N,fc,Ap,Ast,N,,fc,Ap,Ast)

    Program:

    (i) filter order control :N=20;Setspecs (hf,'N,fc,ap,ast',N,fc,ap,ast);hd(6)=design(hf,'equiripple');hfvt=fvtool(hd(5:6));legend (hfvt,'equiripple design,53coefficents','equiripple design,20 coefficents' );

    output:

    0 0.1 0 .2 0 .3 0 .4 0 .5 0.6 0.7 0.8 0.9

    -100

    -9 0

    -8 0

    -7 0

    -6 0

    -5 0

    -4 0

    -3 0

    -2 0

    -1 0

    0

    Normalized Frequency (vT rad/sample)

    M

    agnitu

    de

    (dB)

    Magnitude Response (dB)

    equiripple design,53 coefficents

    equiripple design,20 coefficents

  • 8/3/2019 Sp Lab Report

    46/50

    46

    ii) transition width control :

    setspecs(hf,'N,fp,fst',N,fp,fst);hd(7)=design(hf,'equiripple');measure(hd(7));hfvt=fvtool(hd(5),hd(7));

    legend(hfvt,'equiripple design,53coefficents','equiripple design,20 coefficents' );

    output:

    0 0.1 0 .2 0 .3 0.4 0 .5 0.6 0.7 0.8 0.9

    -100

    -9 0

    -8 0

    -7 0

    -6 0

    -5 0

    -4 0

    -3 0

    -2 0

    -1 0

    0

    Normalized Frequency (vT rad/sample)

    M

    agnitude

    (dB)

    Magnitude Response (dB)

    equiripple design,53 coefficentsequiripple design,20 coefficents

  • 8/3/2019 Sp Lab Report

    47/50

    47

    iii) Stop bend attenuation:

    fc=0.6;

    n=20;

    hf=fdesign.lowpass('n,fc',n,fc);

    fp=0.6;

    fst=0.7725;

    ap=0.01;

    ast=90;

    setspecs(hf,'N,fp,fst',N,fp,fst);

    hd(8)=design(hf,'equiripple','wstop',(5));

    measure(hd(8));

    hfvt=fvtool(hd(7:8));

    Output:

    0 0.1 0 .2 0 .3 0 .4 0 .5 0.6 0.7 0.8 0.9

    -7 0

    -6 0

    -5 0

    -4 0

    -3 0

    -2 0

    -1 0

    0

    Normalized Frequency (vT rad/sample)

    M

    agnitude

    (dB)

    Magnitude Response (dB)

  • 8/3/2019 Sp Lab Report

    48/50

    48

    iv) Design containing:

    fc=0.6;n=20;hf=fdesign.lowpass('n,fc',n,fc);fp=0.6;

    fst=0.7725;ap=0.01;ast=90;setspecs(hf,'fp,fst,ap,ast',fp,fst,ap,ast);hd(9)=design(hf,'equiripple');hfvt=fvtool(hd(8:9));legend(hfvt,'equiripple design using weights','equirippledesign containing the stop band');

    output:

    0 0.1 0 .2 0 .3 0 .4 0 .5 0.6 0.7 0.8 0.9

    -100

    -9 0

    -8 0

    -7 0

    -6 0

    -5 0

    -4 0

    -3 0

    -2 0

    -1 0

    0

    Normalized Frequency (vT rad/sample)

    M

    agnitude

    (dB)

    Magnitude Response (dB)

    equiripple design using w eights

    equiripple design containing the stop band

  • 8/3/2019 Sp Lab Report

    49/50

    49

    EXPERIMENT-28

    Object: write a program for down sampler.

    Program:

    fs=9;t=[0:74]/fs;a1=input('enter the values of amplitude a1=');s1=a1*sin(2*pi*t*.42);subplot(1,2,1);stem(s1);xlabel('sinewave with f=.42Hz');ylabel('amplitude');fs=3;t=[0:74]/fs;s2=a1*sin(2*pi*t*.42);subplot(1,2,2);stem(s2);xlabel('sinewave with f=.42Hz');ylabel('amplitude');

    Output:

  • 8/3/2019 Sp Lab Report

    50/50

    EXPERIMENT-29

    Object: write a program for up sampler.

    Program:

    fs=9;t=[0:74]/fs;a1=input('enter the values of amplitude a1=');s1=a1*sin(2*pi*t*.12);subplot(1,2,1);stem(s1);xlabel('sinewave with f=.12Hz');ylabel('amplitude');s2=upsample(s1,3);subplot(1,2,2);stem(s2);xlabel('sinewave with f=.12Hz');ylabel('amplitude');

    Output :