Matlab Programs for DSP | Scigyan
Showing posts with label Matlab Programs for DSP. Show all posts
Showing posts with label Matlab Programs for DSP. Show all posts

Design filter by Rectangular window function

Matlab program to design filter by Rectangular window function.

Matlab code

clc; close all; clear all
Wc=.5*pi;
taps=25; % No of taps 
N=taps-1; % Filter order 

Analog-to-Digital filter conversion

Matlab program for Analog-to-Digital filter conversion. This program convert Analog Domain signal to Digital domain. 

Matlab code

% Let Transfer function in Analog Domain is (s^2+2s+1)/(s^3+5s^2+11s+15)
clc; close all; clear all; b=[1,2,1];
a=[1,5,11,15];
fs=5; %Sampling frequency

Chebyshev Type 2 Digital Band Stop Filter

Matlab program to design Chebyshev Type 2 Digital Band Stop Filter.

Matlab code

clc; clear all; close all;
rp=input('Enter the Passband ripple (In db) = '); 
rs=input('Enter the Stopband attenuation (In db) = '); 

Chebyshev Type 2 Digital Band Pass Filter

Matlab program to design Chebyshev Type 2 Digital Band Pass Filter.

Matlab code

clc; clear all; close all;
rp=input('Enter the Passband ripple (In db) = '); 
rs=input('Enter the Stopband attenuation (In db) = '); 

Chebyshev Type 2 Digital High Pass Filter

Matlab program to design Chebyshev Type 2 Digital High Pass Filter.

Matlab code

clc; clear all; close all;
rp=input('Enter the Passband ripple (In db) = '); 
rs=input('Enter the Stopband attenuation (In db) = '); 

Chebyshev Type 2 Digital Low Pass Filter

Matlab program to design Chebyshev Type 2 Digital Low Pass Filter.

Matlab code


clc; clear all; close all;
rp=input('Enter the Passband ripple (In db) = '); 
rs=input('Enter the Stopband attenuation (In db) = '); 

Chebyshev Type 1 Digital Band Stop Filter

Matlab program to design Chebyshev Type 1 Digital Band Stop Filter.

Matlab code

clc; clear all; close all;
rp=input('Enter the Passband ripple (In db) = '); 
rs=input('Enter the Stopband attenuation (In db) = '); 

Chebyshev Type 1 Digital Band Pass Filter

Matlab program to design Chebyshev Type 1 Digital Band Pass Filter.

Matlab code

clc; clear all; close all;
rp=input('Enter the Passband ripple (In db) = '); 
rs=input('Enter the Stopband attenuation (In db) = '); 

Chebyshev Type 1 Digital High Pass Filter

Matlab program to design Chebyshev Type 1 Digital High Pass Filter.

Matlab code

clc; clear all; close all;
rp=input('Enter the Passband ripple (In db) = '); 
rs=input('Enter the Stopband attenuation (In db) = '); 

Chebyshev Type 1 Digital Low Pass Filter

Matlab program to design Chebyshev Type 1 Digital Low Pass Filter

Matlab code

clc; clear all; close all;
rp=input('Enter the Passband ripple (In db) = '); 
rs=input('Enter the Stopband attenuation (In db) = '); 

Butterworth Digital Band Stop Filter

Matlab program to design Butter-worth Digital Band Stop Filter.

Matlab code

clc; clear all; close all;
rp=input('Enter the Passband ripple (In db) = '); 
rs=input('Enter the Stopband attenuation (In db) = '); 

Butterworth Digital Band Pass Filter

Matlab program to design Butter-worth Digital Band Pass Filter.

Matlab code

clc; clear all; close all;
rp=input('Enter the Passband ripple (In db) = '); 
rs=input('Enter the Stopband attenuation (In db) = '); 
fpc=input('Enter the Passband corner frequency (In Hz) = ');

Butterworth Digital High Pass Filter

Matlab program to design Butter-worth Digital High Pass Filter.

Matlab code

clc; clear all; close all;
rp=input('Enter the Passband ripple (In db) = ');
rs=input('Enter the Stopband attenuation (In db) = ');

Butterworth Digital Low Pass Filter

Matlab program to design Butter-worth Digital Low Pass Filter.

Matlab code

clc; clear all; close all;
rp=input('Enter the Passband ripple (In db) = '); 
rs=input('Enter the Stopband attenuation (In db) = '); 

Remez exchange algorithm

Matlab program for Remez exchange algorithm.
[n,fo,ao,w] = firpmord(f,a,dev,fs). Finds the approximate order, normalized frequency band edges, frequency band amplitudes, and weights.
b = firpm(n,f,a,w) returns row vector b containing the n+1 coefficients of the order n FIR filter whose frequency-amplitude characteristics match those given by vectors f and a.

Matlab code

clc; clear all; close all;
rp=input('Enter the Passband ripple (In db) = '); 

Circular Convolution Method 3

Matlab program to find Circular Convolution by using for loop function.
Two another methods of Circular Convolution:  Using fft and ifft predefined function and By matrix multiplication.

Matlab code

clc;
close all; clear all;
x=input('Enter the 1st sequence x[n] = '); 
h=input('Enter the 2nd sequence h[n] = ');

Circular Convolution Method 2

Matlab program to find Circular Convolution by matrix multiplication using circshift command.
Two another methods of Circular Convolution:  Using fft and ifft predefined function and By using for loop function.

Matlab code

clc;close all; clear all;
x1=input('Enter the 1st sequence x[n] = ');
h1=input('Enter the 2nd sequence h[n] = ');

Circular Convolution Method 1

Matlab program to find Circular Convolution using fft and ifft predefined function.
Circular Convolution: If x(n) is a sequence of N1 number of samples and h(n) with N2 samples, after convolution y(n) will have N=max(N1,N2) samples.
It cannot be used to find the response of a filter. Zero padding is necessary to find the response of a filter.
Two another methods of Circular Convolution: By matrix multiplication and By using for loop function.

Linear Convolution

Matlab program to find Linear Convolution of given signals.
Linear Convolution: If x(n) is a sequence of N1 number of samples and h(n) with N2 number of samples, after convolution y(n) will have N=N1+N2-1 samples.
It can be used to find the response of a linear filter.
Zero padding is not necessary to find the response of a linear filter.

Matlab code

clc;
clear all; close all;

Z-transform

Matlab program to find Z-transform, Inverse Z-transform, Zeroes and Poles of given sequence.

Matlab code

clc;
close all; clear all; syms n z;
y=input('Enter the sequence x[n]: '); % Where n is sequence variable