Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

N=16

j=sqrt(-1)
n=-2*pi:pi/8:2*pi
y1=sin(n)
Xk=fft(y1,N)
magXk=abs(Xk)
phaXk=angle(Xk)
W=0:1:N-1
subplot(3,1,1)
stem(y1)
axis([0 35 -2 2])
xlabel('Samples')
ylabel('Sine Seq')
title('Original Sequence')
subplot(3,1,2)
stem(W,magXk)
axis([-1 16 0 9])
title('Magnitude Spectrum')
xlabel('Wk')
ylabel('magnitude')
subplot(3,1,3)
stem(W,phaXk)
axis([-1 16 -2 2])
title('Phase spectrum')
xlabel('Wk')
ylabel('phase')

N=
16

j=
0 + 1.0000i

n=
Columns 1 through 7
-6.2832

-5.8905

-5.4978

-5.1051

-4.7124

-4.3197

-3.9270

-2.7489

-2.3562

-1.9635

-1.5708

-1.1781

0.3927

0.7854

1.1781

1.5708

2.7489

3.1416

3.5343

3.9270

4.3197

Columns 8 through 14
-3.5343

-3.1416

Columns 15 through 21
-0.7854

-0.3927

Columns 22 through 28
1.9635

2.3562

Columns 29 through 33

4.7124

5.1051

5.4978

5.8905

6.2832

0.7071

0.9239

1.0000

0.9239

0.7071

-0.3827

-0.7071

-0.9239

-1.0000

-0.9239

0.3827

0.7071

0.9239

1.0000

0.3827

0.0000

-0.3827

-0.7071

-0.9239

-0.7071

-0.3827

-0.0000

y1 =
Columns 1 through 7
0.0000

0.3827

Columns 8 through 14
0.3827

-0.0000

Columns 15 through 21
-0.7071

-0.3827

Columns 22 through 28
0.9239

0.7071

Columns 29 through 33
-1.0000

-0.9239

Xk =
Columns 1 through 4
0.0000

0.0000 - 8.0000i

0.0000 - 0.0000i

0.0000 - 0.0000i

0.0000 - 0.0000i

0.0000 - 0.0000i

0.0000 + 0.0000i

0.0000 + 0.0000i

0.0000 + 0.0000i

0.0000 + 0.0000i

0.0000 + 8.0000i

Columns 5 through 8
0.0000 - 0.0000i

Columns 9 through 12
0.0000

0.0000 - 0.0000i

Columns 13 through 16
0.0000 + 0.0000i

0.0000 + 0.0000i

magXk =
Columns 1 through 7
0.0000

8.0000

0.0000

0.0000

0.0000

0.0000

0.0000

0.0000

0.0000

0.0000

0.0000

0.0000

Columns 8 through 14
0.0000

0.0000

Columns 15 through 16
0.0000

phaXk =

8.0000

Columns 1 through 7
0

-1.5708

-1.4221

-1.5388

-1.5593

-1.5022

-1.3680

-1.2937

1.3680

1.5022

1.5593

1.5388

Columns 8 through 14
1.2937

Columns 15 through 16
1.4221

1.5708

W=
Columns 1 through 13
0

Columns 14 through 16
13

14

15

Published with MATLAB R2012b

10

11

12

You might also like