Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %------------------------------------------Task1
- clc;
- clear all;
- x = [1,2];
- N = 2;
- X = zeros(1,2);
- X(1) = x(1) + x(2);
- X(2) = x(1) - x(2);
- y = fft(x);
- figure
- plot(x);
- figure
- plot(y);
- %-------------------------------------------Task2
- clc;
- clear all;
- close all;
- x = [1,2,3,4];
- N = length(x);
- k = [0,1,2,3];
- Wkn = zeros(1,length(k));
- for i = 1 : length(x)
- Wkn(i) = exp(-2*1i*pi*k(i)/N);
- end
- X = zeros(1,4);
- V11 = x(1) + Wkn(1)*x(3);
- V12 = x(1) - Wkn(1)*x(3);
- V13 = x(2) + Wkn(1)*x(4);
- V14 = x(2) - Wkn(1)*x(4);
- X(1) = V11 + Wkn(1)*V13;
- X(2) = V12 + Wkn(2)*V14;
- X(3) = V11 - V13;
- X(4) = V14*Wkn(2) + V12;
- Y = fft(x);
- subplot(2,1,1)
- stem(X);
- title('My FFT');
- subplot(2,1,2);
- stem(Y);
- title("In-built FFT");
- %---------------------------------------------Task3
- clc;
- clear all;
- close all;
- x = [1, 2, 3, 4];
- X=x;
- N = length(x);
- Half = 1;
- V = log2(N);
- butterfly_no = N/2;
- x = [x, zeros(1, 2^V -N)];
- x = bitrevorder(x);
- for level = 1: V
- for index = 0: 2^level:N-1
- for n = 0 : (Half -1)
- position = n + index + 1;
- power = (2^(V-level))*n;
- w = exp(-2*1i* pi * power /N);
- a = x(position) + x(position + Half).*w;
- b = x(position) - x(position + Half).*w;
- x(position) = a;
- x(position + Half) = b;
- end
- end
- Half = Half * 2;
- end
- subplot(3, 1, 1)
- stem(X);
- title('Input Signal');
- subplot(3,1, 2)
- stem(abs(x));
- title('myFFT');
- subplot(3,1,3)
- Y = fft(X)
- stem(abs(Y));
- title('In-built FFT');
- %---------------------------------------------Task4
- clc;
- clear all;
- close all;
- n=[2 4 8 16 32 64 128];
- N=length(n);
- speed=zeros(1,N);
- for i=1:N
- speed(i)=(n(i)*n(i))/((n(i)/2)*log2(n(i)));
- end
- stem(n,speed);
- ylabel('Speed-factor');
- xlabel('n');
- title('Speed-factor V/s N - 21ucc030');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement