Tuesday, February 22, 2011

0

matlab program for sampling theorem

  • Tuesday, February 22, 2011
  • tech
  • Share
  • %sampling theorm
    clear all;
    t=-10:.01:10;                         %t vector
    T=8;                                  %time period
    fm=1/T;                               %frequency
    x=cos(2*pi*fm*t); %cos wave
    fs1=1.6*fm;                           %fs<2fm
    fs2=2*fm;                             %fs=2fm
    fs3=8*fm;                             %fs>2fm
    n1=-4:1:4;                            %index vector
    xn1=cos(2*pi*n1*fm/fs1);%aliasing
    subplot(2,2,1);
    plot(t,x);
    xlabel('time in sec');
    ylabel('x(t)');
    title('continuous time signal');
    subplot(2,2,2);
    stem(n1,xn1);                          %aliasing discrete
    hold on;
    plot(n1,xn1);                          %aliasing cont
    xlabel('n');
    ylabel('x(n)');
    title('discrete time s/g with fs<2fm');
    n2=-5:1:5;                             %time index
    xn2=cos(2*pi*n2*fm/fs2);               %fs=2fm
    subplot(2,2,3);
    stem(n2,xn2);                          %sampling for fs=2fm
    hold on;
    plot(n2,xn2);                          %ploting fs=2fm
    xlabel('n');
    ylabel('x(n)');
    title('discrete time s/g with fs=2fm');
    n3=-20:1:20;                              %time index
    xn3=cos(2*pi*n3*fm/fs3);                  %fs>2fm
    subplot(2,2,4);
    stem(n3,xn3);                             %samples for fs>2fm
    hold on;
    plot(n3,xn3);                             %ploting fs>2fm
    xlabel('n');
    ylabel('x(n)');
    title('discrete time s/g with fs>2fm');
    output
    tags:matlab program for sampling theorm sampling methods matlab sampling generation using matlab

    0 Responses to “matlab program for sampling theorem”

    Post a Comment