Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % *******************************************************************
- % DSP Project #4
- % *******************************************************************
- FS = 2000; startp = 0; endp = 10;
- N = startp:1/FS:endp;
- % ========================
- % A
- % ========================
- xA = unitstep(0, startp, endp) - unitstep(6, startp, endp);
- yA = (1/FS) * fftshift(fft(xA));
- fA = linspace(-FS/2, FS/2, length(yA));
- figure;
- subplot(1,2,1);
- plot(fA, abs(yA));
- subplot(1,2,2);
- plot(fA, angle(yA));
- % ========================
- % B
- % ========================
- xB = 2.^N .* linspace(0, 0, length(N));
- yB = (1/FS) * fftshift(fft(xB));
- fB = linspace(-FS/2, FS/2, length(yB));
- figure;
- subplot(1,2,1);
- plot(fB, abs(yB));
- subplot(1,2,2);
- plot(fB, angle(yB));
- % reflected unitstep from 0 -> 10 will be 0
- % So akid kolo 7ikon zero -_-
- % ========================
- % C
- % ========================
- xC = (1/4).^N .* linspace(1, 1, length(N));
- yC = (1/FS) * fftshift(fft(xC));
- fC = linspace(-FS/2, FS/2, length(yC));
- figure;
- subplot(1,2,1);
- plot(fC, abs(yC));
- subplot(1,2,2);
- plot(fC, angle(yC));
- % Unit step start before the start point
- % So from -4 or (0 -> startpoint) till the end = 1
- % ========================
- % D
- % ========================
- xD11 = (0.25 .^ N);
- xD12 = sin(2 * pi * 0.25 * N);
- xD1 = xD11 .* xD12;
- xD2 = linspace(1, 1, length(N));
- xD = xD1 .* xD2;
- yD = (1/FS) * fftshift(fft(xD));
- fD = linspace(-FS/2, FS/2, length(yD));
- figure;
- subplot(1,2,1);
- plot(fD, abs(yD));
- subplot(1,2,2);
- plot(fD, angle(yD));
- % ========================
- % E
- % ========================
- xE11 = (0.5 .^ N);
- xE12 = sin(2 * pi * 0.25 * N);
- xE = xE11 .* xE12;
- yE = (1/FS) * fftshift(fft(xE));
- fE = linspace(-FS/2, FS/2, length(yE));
- figure;
- subplot(1,2,1);
- plot(fE, abs(yE));
- subplot(1,2,2);
- plot(fE, angle(yE));
- % ========================
- % F
- % ========================
- startp = -4; endp = 4;
- N = startp:1/FS:endp;
- xF = 2-(0.5 .* N);
- yF = (1/FS) * fftshift(fft(xF));
- fF = linspace(-FS/2, FS/2, length(yF));
- figure;
- subplot(1,2,1);
- plot(fF, abs(yF));
- subplot(1,2,2);
- plot(fF, angle(yF));
- % ========================
- % G
- % ========================
- startp = -2; endp = 2;
- FS = 1;
- N = startp:1/FS:endp;
- xG = [-2 -1 0 1 2];
- yG = fftshift(fft(xG));
- fG = linspace(-1/2, 1/2, length(yG));
- figure;
- subplot(1,2,1);
- plot(fG, abs(yG));
- subplot(1,2,2);
- plot(fG, angle(yG));
Advertisement
Add Comment
Please, Sign In to add comment