Program Code
%Unfolding and Unwrapping of DFTclc;
close all;
clear all;
x=input('Enter the sequence x= ');
N=input('Enter the length of the DFT N= ');
len=length(x);
if N>len
x=[x zeros(1,N-len)];
elseif N<len
x=x(1:N);
end
i=sqrt(-1);
w=exp(-i*2*pi/N);
n=0:(N-1);
k=0:(N-1);
nk=n'*k;
W=w.^nk;
X=x*W;
disp(X);
subplot(411);
stem(k,abs(X));
title('Magnitude plot of unwrapped sequence ');
subplot(412);
stem(k,angle(X));
title('Phase plot ofunwrapped sequence ');
y=X(floor(N/2)+1:N);
Y=[y X(1:floor(N/2))];
subplot(413);
stem(k,abs(Y));
title('Magnitude plot of unfolded spectrum ');
subplot(414);
stem(k,angle(Y));
title('Phase plot of unfolded spectrum ');
Example of Output
Enter the sequence x= [1 1 2 2 3 3 2 2 1 1]Enter the length of the DFT N= 69
Columns 1 through 4
18.0000 16.1310 - 7.0067i 11.1882 -11.9796i 4.8688 -13.6995i
Columns 5 through 8
-0.8338 -12.1898i -4.4438 - 8.5762i -5.5078 - 4.4810i -4.5846 - 1.2845i
Columns 9 through 12
-2.7880 + 0.3832i -1.1687 + 0.7107i -0.2635 + 0.3733i -0.0093 + 0.0449i
Columns 13 through 16
0.0082 + 0.0394i 0.1772 + 0.2510i 0.5978 + 0.3635i 1.0701 + 0.1471i
Columns 17 through 20
1.2925 - 0.3622i 1.1048 - 0.8989i 0.6049 - 1.1673i 0.0716 - 1.0466i
Columns 21 through 24
-0.2337 - 0.6577i -0.2394 - 0.2563i -0.0873 - 0.0379i 0.0000 + 0.0000i
Columns 25 through 28
-0.0920 + 0.0400i -0.2666 + 0.2855i -0.2763 + 0.7775i 0.0905 + 1.3226i
Columns 29 through 32
0.8264 + 1.5948i 1.6598 + 1.3503i 2.1917 + 0.6141i 2.1373 - 0.2938i
Columns 33 through 36
1.5176 - 0.9229i 0.6738 - 0.9545i 0.0829 - 0.3990i 0.0829 + 0.3990i
Columns 37 through 40
0.6738 + 0.9545i 1.5176 + 0.9229i 2.1373 + 0.2938i 2.1917 - 0.6141i
Columns 41 through 44
1.6598 - 1.3503i 0.8264 - 1.5948i 0.0905 - 1.3226i -0.2763 - 0.7775i
Columns 45 through 48
-0.2666 - 0.2855i -0.0920 - 0.0400i -0.0000 + 0.0000i -0.0873 + 0.0379i
Columns 49 through 52
-0.2394 + 0.2563i -0.2337 + 0.6577i 0.0716 + 1.0466i 0.6049 + 1.1673i
Columns 53 through 56
1.1048 + 0.8989i 1.2925 + 0.3622i 1.0701 - 0.1471i 0.5978 - 0.3635i
Columns 57 through 60
0.1772 - 0.2510i 0.0082 - 0.0394i -0.0093 - 0.0449i -0.2635 - 0.3733i
Columns 61 through 64
-1.1687 - 0.7107i -2.7880 - 0.3832i -4.5846 + 1.2845i -5.5078 + 4.4810i
Columns 65 through 68
-4.4438 + 8.5762i -0.8338 +12.1898i 4.8688 +13.6995i 11.1882 +11.9796i
Column 69
16.1310 + 7.0067i
______________________________
No comments:
Post a Comment
Please write your opinion about this MATLAB program here, only in English.