0% found this document useful (0 votes)
55 views12 pages

All All

The document contains MATLAB code that performs various signal processing tasks including: 1) Plotting a continuous and discrete time signal with different sampling frequencies. 2) Taking the discrete Fourier transform (DFT) and inverse discrete Fourier transform (IDFT) of sequences. 3) Checking the stability of a digital filter and designing a finite impulse response (FIR) filter.

Uploaded by

Saravana Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
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)
55 views12 pages

All All

The document contains MATLAB code that performs various signal processing tasks including: 1) Plotting a continuous and discrete time signal with different sampling frequencies. 2) Taking the discrete Fourier transform (DFT) and inverse discrete Fourier transform (IDFT) of sequences. 3) Checking the stability of a digital filter and designing a finite impulse response (FIR) filter.

Uploaded by

Saravana Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 12

1.

clc;
clear all;
close all;
t=-10:.05:10;
T=6;fm=1/T;
x=cos(2*pi*fm*t);
fs1=1.6*fm;
fs2=2*fm;
fs3=6*fm;
n1=-5:1:5;
xn1=cos(2*pi*n1*fm/fs1);
subplot(2,2,1),plot(t,x);
xlabel('Time in sec'),ylabel('x(t)')
title('continuous time signal')
subplot(2,2,2),stem(n1,xn1)
hold on
subplot(2,2,2),plot(n1,xn1)
xlabel('n'),ylabel('x(n)')
title('discrete time signal with fs<2fm')
n2=-5:1:5;
xn2=cos(2*pi*n2*fm/fs2);
subplot(2,2,3),stem(n2,xn2)
hold on
subplot(2,2,3),plot(n2,xn2)
xlabel('n'),ylabel('x(n)')
title('Discrete-time signal with fs=2fm')
n3=-15:1:15;
xn3=cos(2*pi*n3*fm/fs3);
subplot(2,2,4),stem(n3,xn3)
xlabel('n'),ylabel('x(n)')
title('Discrete-time signal with fs>2fm')

2.

Clc;
clear all;
close all;
xn=input('Enter the sequence');
N=input('Enter the number of points in dft');
L=length(xn)
if(N<L)
disp('N must be greater than or equal to L')
end
xk=fft(xn,N)

Op:
Enter the sequence[1 1 1 1 1 1 0 0]
Enter the number of points in dft8

L=

xk =

Columns 1 through 5

6.0000

-0.7071 - 1.7071i 1.0000 - 1.0000i 0.7071 + 0.2929i

Columns 6 through 8

0.7071 - 0.2929i 1.0000 + 1.0000i -0.7071 + 1.7071i

3.

clear all
xk=input('enter the sequence');
xn=ifft(xk

enter the sequence[12 -4+j4 -4 -4-j4]

xn =

2.0000 4.0000 6.0000

4.

SAME PROGRAM

OP:
Enter the numerator coefficients[1 3]
Enter the denominator coefficients[1 3 2]
Enter the sampling time15

T=

15

Transfer function:
z^2 + 3 z + 2
------------z+3

Sampling time: 15

P=

-3

ans =

The given system is unstable


5.
SAME PROGRAM

OP:
enter the order of the filter:49

N=

49

Warning: Could not find an exact (case-sensitive) match for 'FIR1'.


C:\Program Files\MATLAB\R2010a\toolbox\signal\signal\fir1.m is a case-insensitive match and will be
used
instead.
You can improve the performance of your code by using exact
name matches and we therefore recommend that you update your
usage accordingly. Alternatively, you can disable this warning using
warning('off','MATLAB:dispatcher:InexactCaseMatch').
This warning will become an error in future releases.
> In han at 5

h=

Columns 1 through 11

-0.0000 -0.0140 0.0000 0.0154 -0.0000 -0.0170 0.0000 0.0190 -0.0000 -0.0215 0.0000

Columns 12 through 22

0.0248 -0.0000 -0.0293 0.0000 0.0358 -0.0000 -0.0461 0.0000 0.0645 -0.0000 -0.1075

Columns 23 through 33

0.0000 0.3226 0.5067 0.3226 0.0000 -0.1075 -0.0000 0.0645 0.0000 -0.0461 -0.0000

Columns 34 through 44

0.0358 0.0000 -0.0293 -0.0000 0.0248 0.0000 -0.0215 -0.0000 0.0190 0.0000 -0.0170

Columns 45 through 49

-0.0000 0.0154 0.0000 -0.0140 -0.0000

h=

Columns 1 through 11

-0.0000 -0.0011 0.0000 0.0025 -0.0000 -0.0041 0.0000 0.0061 -0.0000 -0.0086 0.0000

Columns 12 through 22

0.0119 -0.0000 -0.0164 0.0000 0.0229 -0.0000 -0.0332 0.0000 0.0516 -0.0000 -0.0946

Columns 23 through 33

0.0000 0.3097 0.5067 0.3097 0.0000 -0.0946 -0.0000 0.0516 0.0000 -0.0332 -0.0000

Columns 34 through 44

0.0229 0.0000 -0.0164 -0.0000 0.0119 0.0000 -0.0086 -0.0000 0.0061 0.0000 -0.0041

Columns 45 through 49

-0.0000 0.0025 0.0000 -0.0011 -0.0000

h=

Columns 1 through 11

-0.0000 -0.0002 0.0000 0.0009 -0.0000 -0.0023 0.0000 0.0043 -0.0000 -0.0073 0.0000

Columns 12 through 22

0.0115 -0.0000 -0.0172 0.0000 0.0252 -0.0000 -0.0372 0.0000 0.0576 -0.0000 -0.1024

Columns 23 through 33

0.0000 0.3171 0.5000 0.3171 0.0000 -0.1024 -0.0000 0.0576 0.0000 -0.0372 -0.0000

Columns 34 through 44

0.0252 0.0000 -0.0172 -0.0000 0.0115 0.0000 -0.0073 -0.0000 0.0043 0.0000 -0.0023

Columns 45 through 49

-0.0000 0.0009 0.0000 -0.0002 -0.0000

h=

Columns 1 through 11

-0.0000 -0.0012 0.0000 0.0017 -0.0000 -0.0029 0.0000 0.0049 -0.0000 -0.0077 0.0000

Columns 12 through 22

0.0118 -0.0000 -0.0174 0.0000 0.0254 -0.0000 -0.0373 0.0000 0.0577 -0.0000 -0.1025

Columns 23 through 33

0.0000 0.3174 0.5005 0.3174 0.0000 -0.1025 -0.0000 0.0577 0.0000 -0.0373 -0.0000

Columns 34 through 44

0.0254 0.0000 -0.0174 -0.0000 0.0118 0.0000 -0.0077 -0.0000 0.0049 0.0000 -0.0029

Columns 45 through 49

-0.0000 0.0017 0.0000 -0.0012 -0.0000

>>

You might also like