bao cao lab 6

  • Upload
    le-vu

  • View
    225

  • Download
    0

Embed Size (px)

Citation preview

  • 8/2/2019 bao cao lab 6

    1/5

    LAB6: Investigation of Aliasing Effects

    1. Exercise 1:

    thy c tc ng chng ph ca tn hiu cos ti tn s 1Khz to ra mt phin bntrn ph, di ph v gii hn mu ca tn hiu.

    1.1V mt tn hiu cosin ti tn s 1Khz t nht 20 chu k. Kch cbc (chu k lymu) l 1/10Khz.Nh vy y l tn hiu trn mu. Dng lnh soundsc chy tnhiu ny.

    Code

    fs = 10000;f = 1000;

    t =-0.01:1/fs:0.01;% the more samples, the longer the sound% t =-0.9:1/fs:0.9; % about 18,000 samplesy = cos(2*pi*f*t);plot(t,y);soundsc(y,fs);

    Hnh vthu c

    -0.01 -0.008 -0.006 -0.004 -0.002 0 0.002 0.004 0.006 0.008 0.01-1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

  • 8/2/2019 bao cao lab 6

    2/5

    S mu cn to ra m thanh t nht l 2 giy nu kch thc bc l 1/10kHz

    fs=10Khz => Ts=0.0001s => s mu cn l

    = 20000 mu

    1.2 V mt tn hiu vi tn s ly mu theo nh l Nyquist.

    Code

    f = 1000;fs = 2*f;t =-0.01:1/fs:0.01;y = cos(2*pi*f*t);plot(t,y);soundsc(y,fs);

    Hnh vthu c

    Tn hiu thu c nghe ging vi phin bn tn hiu trn mu.

    1.3. V mt tn hiu vi tn s ly mu nhhn tn s ly mu theo nh l Nyquist

    Code

    f = 1000;

    -0.01 -0.008 -0.006 -0.004 -0.002 0 0.002 0.004 0.006 0.008 0.01-1

    -0.8

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

  • 8/2/2019 bao cao lab 6

    3/5

    fs = 1.5*f;t =-0.01:1/fs:0.01 ;

    y = cos(2*pi*f*t);plot(t,y);soundsc(y,fs);

    Hnh vthu c

    Tn hiu m thanh nghe nhhn so vi hai tn hiu m thanh trc.

    1.4. Dng lnh plot v 3 tn hiu trn cng mt hnh v.

    Code

    fs1 = 10000;f1 = 1000;

    t1 =-0.01:1/fs1:0.01;y1 = cos(2*pi*f1*t1);

    f2 = 1000;fs2 = 2*f2;t2 =-0.01:1/fs2:0.01;y2 = cos(2*pi*f2*t2);

    f3 = 1000;

    -0.01 -0.008 -0.006 -0.004 -0.002 0 0.002 0.004 0.006 0.008 0.01

    -0.6

    -0.4

    -0.2

    0

    0.2

    0.4

    0.6

    0.8

    1

  • 8/2/2019 bao cao lab 6

    4/5

    fs3 = 3*f3/2;t3 =-0.01:1/fs3:0.01;y3 = cos(2*pi*f3*t3);

    subplot(3,1,1); plot(t1,y1);subplot(3,1,2); plot(t2,y2);

    subplot(3,1,3); plot(t3,y3);grid on;

    Hnh vthu c

    2. Exercise 2:

    Trong bi ny, ta to ra mt tm hnh v bnh xe b v lm cho n quay vi tc khcnhau ca khung (frame). B phim v bnh xe b quay l tn hiu trong min thi gian.

    Nu mt tm hnh quay tn s 10Hz ( 10 vng trn 1 giy) th tn s ly mu Nyquistcn trnh chng ph l 2*10=20 Hz.

    Tiu chun ca phim l 24 hnh trn giy. Tn s cao nht ca chuyn ng khi ti to lim trnh chng ph l 24/2= 12Hz.

    -0.01 -0.008 -0.006 -0.004 -0.002 0 0.002 0.004 0.006 0.008 0.01-1

    0

    1

    -0.01 -0.008 -0.006 -0.004 -0.002 0 0.002 0.004 0.006 0.008 0.01-1

    0

    1

    -0.01 -0.008 -0.006 -0.004 -0.002 0 0.002 0.004 0.006 0.008 0.01-1

    0

    1

  • 8/2/2019 bao cao lab 6

    5/5

    To 3 b phim v 3 phin bn trn mu ( theo chiu kim ng h), di mu ( ngcchiu kim ng h), theo nh l Nyquist. Trong mi trng hp quay ca bnh xe ti tc ging nhau v chthay i tc ca khung trong lnh movie2avi.

    Mi frame quay 360 vi tc 24 frame trn giy th mt 360/24=15 s c 1frame. Vi thi gian 3 giy th s frame l 3*24=72 frame.

    Vit mt hm matlab c tn l wheel.m to ra mt b phim biu din hnh nh spokesquay cng chiu kim ng h ti tc khng i.

    Code

    function [ output ] = wheel(picture, speed, FPS)%UNTITLED2 Summary of this function goes here% Detailed explanation goes heretheta = 0;

    degPerFrame = -speed*360/FPS;for i = 1:FPS*3 % the length of the video is 3s% rotate the imageimage = imrotate(picture, theta, 'bilinear', 'crop');% display the imageimshow(image);pause(0.01) % allow time for the plot to drawmyMovie(i) = getframe(gcf); % capture the frametheta = theta + degPerFrame; % calculate the angle for the next frameendoutput = myMovie;end

    Da vo hm wheel.m, ta to ra 3 bphim nh sau:

    Wheel-oversample.avi

    picture = imread('spokes.tif');matlabMovie = wheel(picture, 10 , 24);movie2avi(matlabMovie, 'wheel-oversampled.avi');

    Wheel-undersample.avi

    picture = imread('spokes.tif');matlabMovie = wheel(picture, 20, 24);movie2avi(matlabMovie, 'wheel-undersampled.avi');

    Wheel-critsample.avi

    picture = imread('spokes.tif');matlabMovie = wheel(picture, 12 , 24);movie2avi(matlabMovie, 'wheel-criticallysampled.avi');