0% found this document useful (0 votes)
16 views6 pages

Type in A N Point Sequence As A Row Vector: (1 2 3 4) Input Sequence 1 2 3 4

Uploaded by

darshansrathod12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views6 pages

Type in A N Point Sequence As A Row Vector: (1 2 3 4) Input Sequence 1 2 3 4

Uploaded by

darshansrathod12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1)

clc; clear all; close all;


x=input('Type in a N point sequence as a row vector:');
N=length(x);
W=dftmtx(N);
X=W*x';
magX=abs(X);
phaX=angle(X);
n=0:N-1; subplot(3,1,1); stem(n,x);
title('Time domain sequence'); xlabel('Time index (n)'); ylabel('Amplitude');
k=0:N-1; subplot(3,1,2); stem(k,magX);
title('Magnitude of DFT'); xlabel('Frequency index (k)'); ylabel('Magnitude');
subplot(3,1,3); stem(k,phaX);
title('Phase of DFT'); xlabel('Frequency index (k)'); ylabel('Phase (radians)');
disp('Input sequence');
disp(x);
disp('DFT of the sequence');
disp(X);
x1=W'*X/N;
disp('Time domain sequence(through IDFT)');
disp(x1)

Type in a N point sequence as a row vector:[1 2 3 4]

Input sequence

1 2 3 4

DFT of the sequence

10.0000 + 0.0000i
-2.0000 + 2.0000i

-2.0000 + 0.0000i

-2.0000 - 2.0000i

Time domain sequence(through IDFT)

1.2)

clc; clear all; close all;

x=input('Type in a N point sequence as a row vector:');


N=length(x);
X=fft(x,N);
magX=abs(X);
phaX=angle(X);
n=0:N-1; subplot(3,1,1); stem(n,x);
title('Time domain sequence'); xlabel('Time index (n)'); ylabel('Amplitude');
k=0:N-1; subplot(3,1,2); stem(k,magX);
title('Magnitude of DFT'); xlabel('Frequency index (k)'); ylabel('Magnitude');
subplot(3,1,3); stem(k,phaX);
title('Phase of DFT'); xlabel('Frequency index (k)'); ylabel('Phase (radians)');
disp('Input sequence');
disp(x);
disp('DFT of the sequence');
disp(X);
x1=ifft(X,N);
disp('Time domain sequence(through IDFT)');
disp(x1)
Type in a N point sequence as a row vector:[1 2 3 4 5 6 7 8]

Input sequence

1 2 3 4 5 6 7 8

DFT of the sequence

Columns 1 through 7

36.0000 + 0.0000i -4.0000 + 9.6569i -4.0000 + 4.0000i -4.0000 + 1.6569i -4.0000 + 0.0000i -
4.0000 - 1.6569i -4.0000 - 4.0000i

Column 8

-4.0000 - 9.6569i

Time domain sequence(through IDFT)

1 2 3 4 5 6 7 8

2)
clc; close all; clear all;
x=[1 2 3 4 5];
y1=circshift(x,1);
y2=circshift(x,2);
y3=circshift(x,3);
y4=circshift(x,4);
y5=circshift(x,5);

disp('Input sequence'); disp(x)


disp('Circularly shifted sequence'); disp(y1)
disp('Circularly shifted sequence'); disp(y2)
disp('Circularly shifted sequence'); disp(y3)
disp('Circularly shifted sequence'); disp(y4)
disp('Circularly shifted sequence'); disp(y5)

output

Input sequence

1 2 3 4 5

Circularly shifted sequence

5 1 2 3 4

Circularly shifted sequence

4 5 1 2 3

Circularly shifted sequence

3 4 5 1 2

Circularly shifted sequence

2 3 4 5 1

Circularly shifted sequence

1 2 3 4 5

Assignment 2)
clc; clear all; close all;
n=0:31;
N=32;
x=cos(2*pi*10*n/64)
subplot(211)
stem(n,x)
X=fft(x,N)
subplot(212)
stem(n, abs(X))

x=

Columns 1 through 13

1.0000 0.5556 -0.3827 -0.9808 -0.7071 0.1951 0.9239 0.8315 0.0000 -0.8315 -0.9239
-0.1951 0.7071

Columns 14 through 26

0.9808 0.3827 -0.5556 -1.0000 -0.5556 0.3827 0.9808 0.7071 -0.1951 -0.9239 -
0.8315 -0.0000 0.8315

Columns 27 through 32

0.9239 0.1951 -0.7071 -0.9808 -0.3827 0.5556


X=

Columns 1 through 6

-0.0000 + 0.0000i -0.0000 - 0.0000i 0.0000 + 0.0000i -0.0000 + 0.0000i -0.0000 - 0.0000i 16.0000
- 0.0000i

Columns 7 through 12

0.0000 - 0.0000i 0.0000 + 0.0000i -0.0000 + 0.0000i -0.0000 - 0.0000i 0.0000 - 0.0000i 0.0000 +
0.0000i

Columns 13 through 18

-0.0000 + 0.0000i -0.0000 - 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i -0.0000 + 0.0000i 0.0000
- 0.0000i

Columns 19 through 24

0.0000 - 0.0000i -0.0000 + 0.0000i -0.0000 - 0.0000i 0.0000 - 0.0000i 0.0000 + 0.0000i -0.0000 +
0.0000i

Columns 25 through 30

-0.0000 - 0.0000i 0.0000 - 0.0000i 0.0000 + 0.0000i 16.0000 + 0.0000i -0.0000 + 0.0000i -0.0000
- 0.0000i

Columns 31 through 32

0.0000 - 0.0000i -0.0000 + 0.0000i

You might also like