Sunteți pe pagina 1din 63

TABLE OF CONTENTS 

1. INTRODUCTION TO MATLAB                                                                                                      2 

2. SUM OF SINUSOIDAL SIGNALS                                                                                                   4    

3. FAST FOURIER TRANSFORM                                                                                                       6      

4. POWER SPECTRAL DENSITY                                                                                                        9  

5. CIRCULAR CONVOLUTION                                                                                                         13        

6. LINEAR CONVOLUTION                                                                                                              18 

7. BUTTERWORTH FILTER                                                                                                              23 

8. CHEBYSHEV FILTER                                                                                                                     27 

9. RECTANGULAR WINDOW                                                                                                          31        

10. KAISER WINDOW                                                                                                                        35          

11. TRIANGULAR WINDOW                                                                                                             39   

  
Date: 
Experiment No.:                                                                                                                                                        2 
 
Overview of the MATLAB® Environment 
The MATLAB® high‐performance language for technical computing integrates computation, 
visualization, and programming in an easy‐to‐use environment where problems and solutions are 
expressed in familiar mathematical notation. Typical uses include 

• Math and Computation 
• Algorithm development 
• Data acquisition 
• Modeling, simulation and prototyping 
• Data analysis, exploration, and visualization 
• Scientific and engineering graphics 
• Application development, including  GUI building 

MATLAB is an interactive system whose basic data element is an array that does not require 
dimensioning. It allows you to solve many technical computing problems, especially those with matrix 
and vector formulations, in a fraction of the time it would take to write a program in a scalar 
noninteractive language such as C or Fortran. 

The name MATLAB stands for matrix laboratory. MATLAB was originally written to provide easy access 
to matrix software developed by the LINPACK and EISPACK projects. Today, MATLAB engines 
incorporate the LAPACK and BLAS libraries, embedding the state of the art in software for matrix 
computation. 

MATLAB has evolved over a period of years with input from many users. In university environments, it is 
the standard instructional tool for introductory and advanced courses in mathematics, engineering, and 
science. In industry, MATLAB is the tool of choice for high‐productivity research, development, and 
analysis. 

MATLAB features a family of add‐on application‐specific solutions called toolboxes. Very important to 
most users of MATLAB, toolboxes allow you to learn and apply specialized technology. Toolboxes are 
comprehensive collections of MATLAB functions (M‐files) that extend the MATLAB environment to solve 
particular classes of problems. You can add on toolboxes for signal processing, control systems, neural 
networks, fuzzy logic, wavelets, simulation, and many other areas 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        3 
 
The MATLAB® System 
The MATLAB system consists of these main parts: 
 
Desktop Tools and Development Environment 
This is the set of tools and facilities that help you use and become more productive with MATLAB 
functions and files. Many of these tools are graphical user interfaces. It includes the MATLAB desktop 
and Command Window, a command history, an editor and debugger, a code analyzer and other reports, 
and browsers for viewing help, the workspace, files, and the search path. 
 
Mathematical Function Library 
This is a vast collection of computational algorithms ranging from elementary functions, like sum, sine, 
cosine, and complex arithmetic, to more sophisticated functions like matrix inverse, matrix eigenvalues, 
Bessel functions, and fast Fourier transforms. 
 
The Language 
This is a high‐level matrix/array language with control flow statements, functions, data structures, 
input/output, and object‐oriented programming features. It allows both "programming in the small" to 
rapidly create quick and dirty throw‐away programs, and "programming in the large" to create large and 
complex application programs. 
 
Graphics 
MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as annotating and 
printing these graphs. It includes high‐level functions for two‐dimensional and three‐dimensional data 
visualization, image processing, animation, and presentation graphics. It also includes low‐level 
functions that allow you to fully customize the appearance of graphics as well as to build complete 
graphical user interfaces on your MATLAB applications. 
 
External Interfaces 
This is a library that allows you to write C and Fortran programs that interact with MATLAB. It includes 
facilities for calling routines from MATLAB (dynamic linking), for calling MATLAB as a computational 
engine, and for reading and writing MAT‐files. 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        4 
 
1. SUM OF SINUSOIDAL SIGNALS 
Aim: ‐                                                                                                                                                                                                               
To find out the sum of sinusoidal signals using MATLAB® software. 

Apparatus: ‐                                                                                                                                                                          
MATLAB® Software  

Theory: ‐                                                                                                                                                                                          
A sinusoidal signal is a continuous time signal which is defined over a continuous range of time. A 
sinusoidal signal is given by  

X (t) =Asin (Ωt+ Φ) 

Where A is the amplitude of the signal                

             Ω is the frequency in radians 

             Φ is the phase in radians.         

MATLAB® Program:‐ 

clc;
clear;
x=-pi:0.04:pi;
y=sin(x)+2*cos(x)+sin(3*x);
plot(y);
title('Sum Of Sinusoidal Signals');
xlabel('Radians');
ylabel('Amplitude');

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        5 
 
Waveform:‐ 

Result:‐ 

             Thus the sum of sinusoids are found using MATLAB®. 

                                                                                                                                                                   

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        6 
 
2. FAST FOURIER TRANSFORM 
Aim: ‐                                                                                                                                                                                                 
To verify the Fast Fourier transform using MATLAB® 

Apparatus: ‐                                                                                                                                                                                                   
MATLAB® Software  

Theory: ‐                                                                                                                                                                                              
A fast Fourier transform is an efficient algorithm to compute Discrete Fourier Transform (DFT) and its 
inverse. A DFT decomposes a sequence of values into components of different frequencies but 
computing it directly from the definition is often too slow to be practical. An FFT is a way to compute the 
same result more quickly: computing a DFT of N points in the naive way, using the definition, takes O(N2) 
arithmetical operations, while an FFT can compute the same result in only O(N log N) operations. The 
difference in speed can be substantial, especially for long data sets where N may be in the thousands or 
millions—in practice, the computation time can be reduced by several orders of magnitude in such 
cases, and the improvement is roughly proportional to N/log(N). This huge improvement made many 
DFT‐based algorithms practical; FFTs are of great importance to a wide variety of applications, from 
digital signal processing and solving partial differential equations to algorithms for quick multiplication 
of large integers. 

MATLAB® Program:‐ 

clc;
clear;
s=input('Enter the Sequence:');
n=input('Enter the Length:');
y=fft(s,n);
subplot(2,1,1);
stem(s);
title('Sequence');
subplot(2,1,2);
stem(y);
title('Fourier Transform');
 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        7 
 
Theoretical Calculations:‐ 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        8 
 
Output:‐ 

Enter the Sequence: [1 2 3 4 4 3 2 1] 

Enter the Length: 8 

Waveform:‐ 

Result:‐ 

             Thus the Fast Fourier Transform of the given sequence is found using MATLAB®. 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        9 
 
3. POWER SPECTRAL DENSITY 
Aim: ‐                                                                                                                                                                                                
To verify the power spectral density of a given sequence using MATLAB® Software.          

Apparatus: ‐                                                                                                                                                                                     
MATLAB® Software  

Theory: ‐                                                                                                                                                         
The power spectral density (PSD), which describes how the power of a signal or time series is 
distributed with frequency. Here power can be the actual physical power, or more often, for 
convenience with abstract signals, can be defined as the squared value of the signal, that is, as 
the actual power dissipated in a load if the signal were a voltage applied to it. This 
instantaneous power (the mean or expected value of which is the average power) is then given 
by 

P (t) = s (t)2 
Since a signal with nonzero average power is not square integrable, the Fourier transforms do 
not exist in this case. Fortunately, the Weiner‐Khinchin theorem provides a simple alternative. 
The PSD is the Fourier transform of the Autocorrelation function, R(τ), of the signal if the signal 
can be treated as a wide sense stationary random process. This results in the formula, 

The power of the signal in a given frequency band can be calculated by integrating over positive 
and negative frequencies, 

The power spectral density of a signal exists if and only if the signal is a wide‐sense stationary 
process. If the signal is not stationary, then the autocorrelation function must be a function of 
two variables, so no PSD exists, but similar techniques may be used to estimate a time‐varying 
spectral density. 

The power spectrum G(f) is defined as 

 
 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        10 
 
MATLAB® Program: ‐ 

clear all;
x=input('Enter the sequence:');
y=xcorr(x,x);
disp('Autocorrelation is:');
disp(y);
n=4;
p=fft(y,n);
figure;
subplot(3,1,1)
stem(x);
title('Input Sequence');
subplot(3,1,2);
stem(y);
title('Auto Correlation Function');
subplot(3,1,3);
stem(p);
title('Power Spectral Density');
 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        11 
 
Theoretical Calculations:‐ 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        12 
 
Output: ‐ 

Enter the sequence:[1 1 1 1] 

Autocorrelation is: 

     1     2     3     4     3     2     1 

Waveform: ‐ 

Result: ‐ 

             Thus the Power Spectral Density of the given sequence is found using MATLAB®. 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        13 
 
4. CIRCULAR CONVOLUTION 
Aim: ‐                                                                                                                                                                                                   
To verify circular convolution using MATLAB®. 

Apparatus: ‐                                                                                                                                                                             
MATLAB® Software  

Theory: ‐                                                                                                                                                       
For a periodic function xT(t), with period T, the convolution with another function, h(t), is also 
periodic, and can be expressed in terms of integration over a finite interval as follows: 

where to is an arbitrary parameter, and hT(t) is a periodic extension of h, defined by: 

When xT(t) is expressed as the periodic extension of another function, x, this convolution is 
sometimes referred to as a circular convolution of functions h and x. 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        14 
 
MATLAB® Program: ‐ 

clear all;
g=input('Enter the sequence x1:');
h=input('Enter the sequence x2:');
n1=length(g);
n2=length(h);
n=max(n1,n2);
n3=n1-n2;
if(n3>0)
h=[h,zeros(1,n3)];
else
g=[g,zeros(1,n3)];
end;

for a=1:n
y(a)=0;
for i=1:n
j=a-i+1;
if(j<1)
j=n+j;
end;
y(a)=y(a)+g(i)*h(j);
end;
end;
display('Circular Convolution');
display(y);
s=length(y);
figure
subplot(3,1,1)
stem(g)
title('First sequence');
xlabel('n')
ylabel('Amplitude');
subplot(3,1,2)
stem(h)
title('Second sequence');

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        15 
 
xlabel('n')
ylabel('Amplitude');
subplot(3,1,3)
stem(y)
title('Circular Convolution');
xlabel('n')
ylabel('Amplitude');
display('Length of first sequence:')
display(n1);
display('Length of second sequence:');
display(n2);
display('Length of resultant output:');
display(s);
 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        16 
 
Theoretical Calculations:‐ 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        17 
 
Output: ‐ 

Enter the sequence x1:[4 2 1]                                                                                   

Enter the sequence x2:[2 1 0]                                                     

Circular Convolution y =     9     8     4 

Length of first sequence: n1 =     3 

Length of second sequence: n2 =     3 

Length of resultant output: s =     3 

Waveform: ‐ 

Result:‐ 

             Thus the circular convolution of the given sequences is found out. 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experime
ent No.:                                                                                                                                                        18 
 
5. LINEAR
R CONVOLU
UTION 
Aim: ‐                                                                                                                                                                                                     
To find ou ut the linear cconvolution o of two sequen nces using MA ATLAB®. 

Apparatus: ‐                                                                                                                                                                                                   
MATLAB®® Software  

Theory:‐                                                                                                                                                                          
Convoluttion is an integral concattenation of ttwo signals. It has manyy applications in numeroous 
areas of ssignal proceessing. The m
most popularr application
n is the deterrmination off the output 
signal of a linear timee‐invariant ssystem by co
onvolving the input signaal with the impulse resp
ponse 
of the sysstem.  
Note that convolvingg two signalss is equivalennt to multiplying the Fouurier transfo
orm of the tw
wo 
signals.  

Mathematic Formulaa: 
The lineaar convolutio
on of two co
ontinuous tim
me signals  and  is defined b
by  

For discrete time sign
nals  an
nd  , thee integration is replaced by a summaation  

Graphicaal Interpretaation: 

• Reflection of  resulting in   
• Shifting of  resulting in   
• Element wise e multiplication of the seequences  and   
• Summation o of the producct sequence  resulting iin the convo
olution valuee for 
 

BHAR
RAT INSTITTUTE OF EN
NGINEERIN
NG AND TEECHNOLOG
GY 
Date: 
Experiment No.:                                                                                                                                                        19 
 
MATLAB® Program: ‐ 

clear all;
a=input('Enter the sequence 1');
b=input('Enter the sequence 2');
m=length(a);
n=length(b);
p=m+n-1;
a=[a,zeros(1,p-m)];
b=[b,zeros(1,p-m)];
for k=1:p
y(k)=0;
for i=1:k
y(k)=y(k)+a(i)*b(k-i+1);
end;
end;
display('Linear Convolution');
display(y);
s=length(y);
figure
subplot(3,1,1)
stem(a)
title('First Sequence');
xlabel('n');
ylabel('Amplitude');
subplot(3,1,2)
stem(b)
title('Second Sequence');
xlabel('n');
ylabel('Amplitude');
subplot(3,1,3)
stem(y)
title('Linear Convolution');
xlabel('n');
ylabel('Amplitude');
display('Length of first sequence');
display(m);
display('Length of second sequence');

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        20 
 
display(n);
display('Length of resultant output');
display(s);
 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        21 
 
Theoretical Calculations:‐ 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        22 
 
Output: ‐ 

Enter the sequence 1:[1 2 4]                                      
Enter the sequence 2:[1 2 0]                                     
Linear Convolution: y =     1     4     8     8     0                               
Length of first sequence: m =     3                                                
Length of second sequence: n =     3                                              
Length of resultant output: s =     5 

Waveform: ‐ 

Result: ‐ 

              Thus the linear convolution of the given two sequences is found out using MATLAB®. 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experime
ent No.:                                                                                                                                                        23 
 
6. BUTTER
RWORTH FFILTER 
Aim: ‐                                                                                                                                                                                                  
To Verify the operation n of Butterwo orth Filter using MATLAB® 

Apparatus:‐                                                                                                                                                                                    
MATLAB®® Software  

Theory: ‐                                                                                                                                                                        
The Butte erworth filterr is a type of ssignal processsing filter dessigned to havee as flat a freq quency respo onse  
as possible in the pass band so thatt it is also term med a maxim mally flat maggnitude filter. The frequency 
response of the Butterrworth filter is maximally fflat in the passs band, and rrolls off towards zero in th he 
stop band d. When view wed on logarithmic bode plot, the respo onse slopes offf linearly tow wards negative 
infinity. Fo
or a first orde er filter, the response rollss off at ‐6dB p per octave. Fo or a second order low passs 
filter, the response ultimately decreeases at ‐12dB per octave,, a third order at ‐18dB per octave and so 
on. 

   Butterworth filters have a m monotonicallyy changing magnitude function with ω, unlike other filter 
types thatt have non‐m monotonic ripp ple in the passsband and/o or the stopban nd. Compared d with a 
Chebysheev Type I/Type e II filter or an
n elliptic filter, the Butterw
worth filter haas a slower rooll‐off, and th
hus 
will requirre a higher orrder to implement a particcular stopban nd specificatio
on, but Butterrworth filterss have 
a more linnear phase re esponse in thee pass‐band tthan Chebyshev Type I/Typ pe II and elliptic filters can 
achieve. 

The gain G(ω) of an n-order Buttterworth low


w pass filter is
i given in teerms of the transfer
t funcction
H(s) as;

where

• n = order of filter
f
• ωc = cut off frequency
fr (appproximatelyy the -3dB frequency)
fr
• G0 is the DC gain (gain at zero frequeency)

BHAR
RAT INSTITTUTE OF EN
NGINEERIN
NG AND TEECHNOLOG
GY 
Date: 
Experiment No.:                                                                                                                                                        24 
 
MATLAB® Program: ‐ 

clear all;
rp=input ('Enter the pass band ripple:');
rs=input ('Enter the stop band ripple:');
wp=input ('Enter the pass band frequency:');
wq=input ('Enter the stop band frequency:');
ws=input ('Enter the sampling frequency:');
w1=2*wp/ws;
w2=2*wq/ws;
[n,wn]=buttord (w1,w2,rp,rs);
% low pass filter
[b,a]=butter(n,wn);
w=0:0.01:pi;
[h,omg]=freqz (b,a,w);
m=20*log10 (abs (h));
an=angle (h);
subplot (2,2,1);
plot (omg/pi,m);
title('ButterWorth Low Pass Filter');
xlabel ('Normalised frequency');
ylabel ('Gain(dB)');
grid on;
subplot (2,2,2);
plot (omg/pi,an);
title('ButterWorth Low Pass Filter');
xlabel ('Normalised frequency');
ylabel ('Gain(dB)');
grid on;
% high pass filter
[b,a]=butter (n,wn,'high');
w=0:0.01:pi;
[h,omg]=freqz (b,a,w);
m=20*log10 (abs (h));
an=angle (h);
subplot (2,2,3);
plot (omg/pi,m);
title('ButterWorth High Pass Filter');

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        25 
 
xlabel ('Normalised frequency');
ylabel ('Gain(dB)');
grid on;
subplot (2,2,4);
plot (omg/pi,an);
title('ButterWorth High Pass Filter');
xlabel ('Normalised frequency');
ylabel ('Gain(dB)');
grid on;
 

OUTPUT: ‐ 

Enter the pass band ripple:.5 

Enter the stop band ripple:50 

Enter the pass band frequency:1200 

Enter the stop band frequency:2400 

Enter the sampling frequency:10000 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        26 
 
Waveform: ‐ 

Result: ‐ 

               Thus the Butterworth filter is designed as per the given parameters using MATLAB® 

 
 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        27 
 
7. CHEBYSHEV FILTER 
Aim: ‐                                                                                                                                                                                            
To verify the operation of IIR Chebyshev Filter using MATLAB® 

Apparatus: ‐                                                                                                                                                                        
MATLAB® Software  

Theory: ‐                                                                                                                                         
Chebyshev filters are analog or digital filters having a steeper roll‐off and more passband ripple 
(type I) or stopband ripple (type II) than Butterworth filters. Chebyshev filters have the property 
that they minimize the error between the idealized and the actual filter characteristic over the 
range of the filter, but with ripples in the passband. This type of filter is named in honor of 
Pafnuty Chebyshev because their mathematical characteristics are derived from Chebyshev 
polynomials.Because of the passband ripple inherent in Chebyshev filters, filters which have a 
smoother response in the passband but a more irregular response in the stopband are 
preferred for some applications. The gain response as a function of angular frequency ω of the 
nth order low pass filter is 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        28 
 
MATLAB® Program: ‐ 
clear all;
rp=input ('Enter the passband ripple:');
rs=input ('Enter the stopband ripple:');
wp=input ('Enter the passband frequency:');
wq=input ('Enter the stopband frequency:');
ws=input ('Enter the sampling frequency:');
w1=2*wp/ws;
w2=2*wq/ws;
[n,wn]=cheb1ord (w1,w2,rp,rs);
% lowpassfilter
[b,a]=cheby1 (n,rp,wn);
w=0:0.01:pi;
[h,omg]=freqz (b,a,w);
m=20*log10 (abs (h));
an=angle (h);
subplot (2,2,3);
plot (omg/pi,m);
title('Chebyshev Low Pass Filter');
xlabel ('Normalised frequency');
ylabel ('Gain(dB)');
grid on;
subplot (2,2,4);
plot (omg/pi,an);
title('Chebyshev Low Pass Filter');
xlabel ('Normalised frequency');
ylabel ('Gain(dB)');
grid on;
% highpass filter
[b,a]=cheby1 (n,rp,wn,'high');
w=0:0.01:pi;
[h,omg]=freqz (b,a,w);
m=20*log10 (abs (h));
an=angle (h);
subplot (2,2,1);
plot (omg/pi,m);
title('Chebyshev High Pass Filter');

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        29 
 
xlabel ('Normalised frequency');
ylabel ('Gain(dB)');
grid on;
subplot (2,2,2);
plot (omg/pi,an);
title('Chebyshev High Pass Filter');
xlabel ('Normalised frequency');
ylabel ('Gain(dB)');
grid on;
 

Output: ‐ 

Enter the pass band ripple:.5 

Enter the stop band ripple:50 

Enter the pass band frequency:1200 

Enter the stop band frequency:2400 

Enter the sampling frequency:10000 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        30 
 
Waveform: ‐ 

Result: ‐ 

             Thus chebyshev filter is designed as per the given parameters using MATLAB® 

 
 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        31 
 
8. RECTANGULAR WINDOW TECHNIQUE 
Aim: ‐                                                                                                                                                                                               
To verify the operation of FIR Filters using Rectangular windowing technique. 

Apparatus:‐                                                                                                                                                                                    
MATLAB® Software  

Theory:‐The simplest method to bound the idea derivative reconstruction filter to some extend is to 
truncate it. This is the tantamount to the multiplying it with a rectangular function which is 1 inside 
some extend and 0 outside. 

⎧1 | x |< τ ⎫
Re ct ( x,τ ) = ⎨ ⎬ 
⎩0 else ⎭

Although the frequency response approximates the ideal one quire good below π, it is significantly 
different from the zero in form of bumps above, which is due to the truncation and particularly annoying 
in gradient reconstruction because it introduces artifacts even more perceivable than in function 
reconstruction. To avoid these bumps, other windows trade them against the rather good 
approximation below π. 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        32 
 
MATLAB® Program: ‐ 

clear all;
rp=input('Enter the pass band ripple:');
rs=input('Enter the stop band ripple:');
wp=input('Enter the pass band frequency:');
wr=input('Enter the stop band frequency:');
ws=input('Enter the sampling frequency:');
w1=2*wp/ws;
w2=2*wr/ws;
nume=-20*log10(sqrt(rp*rs))-13;
denm=14.6*(wr-wp)/ws;
n=ceil(nume/denm);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end;
y=rectwin(n1);
%low pass filter
b=fir1(n,w1,y);
[h,omg]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(omg/pi,m);
title('Low Pass filter');
ylabel('Gain(dB)');
xlabel('Normalised Frequency.');
grid on;
%high pass filter
b=fir1(n,w1,'high',y);
[h,omg]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(omg/pi,m);
title('High Pass filter');
ylabel('Gain(dB)');
xlabel('Normalised Frequency.');

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        33 
 
grid on;
%badn pass filter
wn=[w1,w2];
b=fir1(n,wn,y);
[h,omg]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,3);
plot(omg/pi,m);
title('Band Pass filter');
ylabel('Gain(dB)');
xlabel('Normalised Frequency.');
grid on;
%band stop filter
b=fir1(n,wn,'stop',y);
[h,omg]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,4);
plot(omg/pi,m);
title('Band stop filter');
ylabel('Gain(dB)');
xlabel('Normalised Frequency.');
grid on;

Output: ‐ 

Enter the pass band ripple:0.05 

Enter the stop band ripple:0.02 

Enter the pass band frequency:1500 

Enter the stop band frequency:2500 

Enter the sampling frequency:10000 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        34 
 
Waveform: ‐ 

Result: ‐ 

           Thus FIR filter is realized using rectangular window technique in MATLAB® 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        35 
 
9. KAISER WINDOW 
Aim: ‐                                                                                                                                                                                                
To verify the operation of FIR Filters using Kaiser Window Technique.  

Apparatus: ‐                                                                                                                                                                         
MATLAB® Software  

Theory: ‐
The Kaiser window is a one-parameter family of window functions used for digital signal
processing , and is defined by the formula :

where:

• I0 is the zeroth order modified Bessel function of first kind.


• α is an arbitrary real number that determines the shape of the window. In the frequency
domain, it determines the trade-off between main-lobe width and side lobe level, which is
a central decision in window design.
• M is an integer, and the length of the sequence is N=M+1.

The higher the α the narrower gets the window and therefore due to the not so severe truncation then, 
the less severe are the bumps above π. Goss used this window to obtain the adjustable gradient filter, 
but he used only on sample points so that, in between sample points, some kind of interpolation has to 
be performed, which he does not state explicitly.  

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        36 
 
MATLAB® Program: ‐ 

clear all;
rp=input('Enter the pass band ripple:');
rs=input('Enter the stop band ripple:');
wp=input('Enter the pass band frequency:');
wr=input('Enter the stop band frequency:');
ws=input('Enter the sampling frequency:');
beta=input('Enter the beta value');
w1=2*wp/ws;
w2=2*wr/ws;
nume=-20*log10(sqrt(rp*rs))-13;
denm=14.6*(wr-wp)/ws;
n=ceil(nume/denm);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end;
y=kaiser(n1,beta);
%low pass filter
b=fir1(n,w1,y);
[h,omg]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(omg/pi,m);
title('Low Pass Filter');
ylabel('Gain(dB)');
xlabel('Normalised Frequency.');
grid on;
%high pass filter
b=fir1(n,w1,'high',y);
[h,omg]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(omg/pi,m);
title('High Pass Filter');
ylabel('Gain(dB)');

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        37 
 
xlabel('Normalised Frequency.');
grid on;
%band pass filter
wn=[w1,w2];
b=fir1(n,wn,y);
[h,omg]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,3);
plot(omg/pi,m);
title('Band Pass filter');
ylabel('Gain(dB)');
xlabel('Normalised Frequency.');
grid on;
%band stop filter
wn=[w1,w2];
b=fir1(n,wn,'stop',y);
[h,omg]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,4);
plot(omg/pi,m);
title('Band stop filter');
ylabel('Gain(dB)');
xlabel('Normalised Frequency.');
grid on;
 

Output: ‐ 

Enter the pass band ripple:0.05 

Enter the stop band ripple:0.02 

Enter the pass band frequency:1500 

Enter the stop band frequency:2500 

Enter the sampling frequency:10000 

Enter the beta value5.8 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        38 
 
Waveform: ‐ 

Result: ‐ 

              Thus FIR filter is realized using Kaiser Window in MATLAB®.  

 
 

 
 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        39 
 
10. TRIANGULAR WINDOW 
Aim: ‐                                                                                                                                                                                               
To verify the operation of FIR filter using Triangular (Bartlett) windowing technique.  

Apparatus:‐                                                                                                                                                                                                    
MATLAB® Software  

Theory:‐  A Bartlett window is simply a function given by 

⎧ | x| ⎫
⎪1 − | x |< τ ⎪
Bartlett ( x,τ ) = ⎨ τ ⎬ 
⎩⎪0 else ⎭⎪

The frequency response approaches zero more smoothly but does not approximate the ideal frequency 
response below π as good as the truncated functions. This rather simple windowing function , although  
said to be sufficient performs quite poor when used for gradient reconstruction. 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        40 
 
MATLAB® Program: ‐ 

clear all;
rp=input('Enter the pass band ripple:');
rs=input('Enter the stop band ripple:');
fp=input('Enter the pass band frequency:');
fs=input('Enter the stop band frequency:');
f=input('Enter the sampling frequency:');
wp=2*fp/f;
ws=2*fs/f;
nume=-20*log10(sqrt(rp*rs))-13;
denm=14.6*(fs-fp)/f;
n=ceil(nume/denm);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end;
y=triang(n1);
%low pass filter
b=fir1(n,wp,y);
[h,omg]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(omg/pi,m);
title('Low Pass Filter');
ylabel('Gain(dB)');
xlabel('Normalised Frequency.');
grid on;
%high pass filter
b=fir1(n,wp,'high',y);
[h,omg]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(omg/pi,m);
title('High Pass Filter');
ylabel('Gain(dB)');
xlabel('Normalised Frequency.');

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        41 
 
grid on;
%band pass filter
wn=[wp,ws];
b=fir1(n,wn,y);
[h,omg]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,3);
plot(omg/pi,m);
title('Band Pass filter');
ylabel('Gain(dB)');
xlabel('Normalised Frequency.');
grid on;
%band stop filter
b=fir1(n,wn,'stop',y);
[h,omg]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,4);
plot(omg/pi,m);
title('Band stop filter');
ylabel('Gain(dB)');
xlabel('Normalised Frequency.');
grid on;
 

Output – 

Enter the pass band ripple:0.05 

Enter the stop band ripple:0.02 

Enter the pass band frequency:1500 

Enter the stop band frequency:2500 

Enter the sampling frequency:10000 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        42 
 
Waveform: ‐ 

Result: ‐ 

              Thus FIR filter is realized using triangular window technique in MATLAB® 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experime
ent No.:                                                                                                                                                        43 
 
DIG
GITAL SIG
GNAL PRO
OCESSORS

A digital signal proceessor (DSP) is a specialiized microprrocessor withh an optimizzed architectuure
for the faast operation
nal needs of digital
d signaal processingg.

Typical characterist
c tics

Digital siignal processing algorithhms typicallyy require a laarge numberr of mathematical operattions
to be performed quicckly and repeetitively on a set of data.. Signals (peerhaps from audio
a or video
sensors) are constanttly convertedd from analoog to digital, manipulatedd digitally, and
a then
convertedd again to an nalog form, as
a diagramm med below. Many
M DSP applications
a h
have constraaints
on latenccy; that is, fo
or the system
m to work, thhe DSP operaation must be completedd within som me
fixed tim
me, and deferrred (or batchh) processing is not viabble.

Most genneral-purpose microproccessors and operating


o sysstems can exxecute DSP algorithms
a
successfuully, but are not suitable for use in portable devicces such as mobile
m phonnes and PDAAs
because ofo power sup pply and spaace constrainnts. A speciaalized digitall signal proceessor, howevver,
will tendd to provide a lower-cost solution, wiith better perrformance, lower
l latencyy, and no
requiremments for speccialized coolling or largee batteries.

The architecture of a digital signal processorr is optimizedd specifically for digital signal
processinng. Most also o support some of the feeatures as an applicationss processor or o
microconntroller, sincce signal proccessing is raarely the onlyy task of a syystem. Somee useful featuures
for optim
mizing DSP algorithms
a are outlined below.
b

Architeccture

By the sttandards of general


g purpose processoors, DSP insttruction setss are often hiighly irregullar.
One impllication for software
s architecture is that
t hand opptimized asseembly is com mmonly
packagedd into libraries for re-usee, instead of relying on unusually
u advvanced comppiler
technologgies to handle essential algorithms.
a

Hardware features viisible througgh DSP instruuction sets commonly


c innclude:

• Hardware mo
H odulo addresssing, allowinng circular buffers
b to be implementeed without
having to connstantly test for
f wrappingg.
• M
Memory arch
hitecture desiigned for strreaming dataa, using DMA A extensivelly and expeccting
coode to be wrritten to know
w about cachhe hierarchiees and the asssociated dellays.

BHAR
RAT INSTITTUTE OF EN
NGINEERIN
NG AND TEECHNOLOG
GY 
Date: 
Experiment No.:                                                                                                                                                        44 
 
• Driving multiple arithmetic units may require memory architectures to support several
accesses per instruction cycle
• Separate program and data memories (Harvard architecture), and sometimes concurrent
access on multiple data busses
• Special SIMD (single instruction, multiple data) operations
• Some processors use VLIW techniques so each instruction drives multiple arithmetic
units in parallel
• Special arithmetic operations, such as fast multiply-accumulates (MACs). Many
fundamental DSP algorithms, such as FIR filters or the Fast Fourier transform (FFT)
depend heavily on multiply-accumulate performance.
• Bit-reversed addressing, a special addressing mode useful for calculating FFTs
• Special loop controls, such as architectural support for executing a few instruction words
in a very tight loop without overhead for instruction fetches or exit testing
• Deliberate exclusion of a memory management unit. DSPs frequently use multi-tasking
operating systems, but have no support for virtual memory or memory protection.
Operating systems that use virtual memory require more time for context switching
among processes, which increases latency.

Program flow

• Floating-point unit integrated directly into the datapath


• Pipelined architecture
• Highly parallel multiplier–accumulators (MAC units)
• Hardware-controlled looping, to reduce or eliminate the overhead required for looping
operations

Memory architecture

• DSPs often use special memory architectures that are able to fetch multiple data and/or
instructions at the same time:
o Harvard architecture
o Modified von Neumann architecture
• Use of direct memory access
• Memory-address calculation unit

Data operations

• Saturation arithmetic, in which operations that produce overflows will accumulate at the
maximum (or minimum) values that the register can hold rather than wrapping around
(maximum+1 doesn't overflow to minimum as in many general-purpose CPUs, instead it
stays at maximum). Sometimes various sticky bits operation modes are available.
• Fixed-point arithmetic is often used to speed up arithmetic processing
• Single-cycle operations to increase the benefits of pipelining

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        45 
 
 Instruction sets 

• Multiply‐accumulate (MAC, aka fused multiply‐add, FMA) operations, which are used 
extensively in all kinds of matrix operations, such as convolution for filtering, dot product, or 
even polynomial evaluation (see Horner scheme) 
• Instructions to increase parallelism: SIMD, VLIW, superscalar architecture 
• Specialized instructions for modulo addressing in ring buffers and bit‐reversed addressing mode 
for FFT cross‐referencing 
• Digital signal processors sometimes use time‐stationary encoding to simplify hardware and 
increase coding efficiency. 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experime
ent No.:                                                                                                                                                        46 
 
TMS320C6
T 6713 DIGITAL SIGN
NAL PROC
CESSOR 

TMS320C6713 is a mem mber of the ffamily TMS32 20C67XX whicch all have esssentially the ssame CPU (th


he 
DSP core)) with VLIW (V
Very long insttruction word
d) architecture. 

A function
nal block diaggram of TMS3
320C6713 is aas follows 

C67x DSP Core 

The CPU aalways fetche es  eight 32 biit instructionss at once via aa 256 bit bus from the inteernal program

memory.TThis group of 8 instruction ns is called a fetch packet.TThe CPU has 8 8 functional u
units which caan 
work in paarallel divided
d into two gro oups A and B by the data p paths.These eeight units are 

n perform both fixed and ffloating pointt operations(LL1,L2,S1,S2) 
1.Four ALU’s which can

U’s which can
2.Two ALU n perform onlly fixed point operations(D
D1,D2) 

3.Two mu
ultipliers that can perform both fixed an
nd floating po
oint operation
ns(M1,M2) 

32  32‐bit general purp
pose register bank is provided split equally between the sides A aand B.The CPU U has 
load/storee architecture
e and the datta addressing units Data paath A and B aare in charge o
of all the 
operationns between thhe register filee and memorry.The four fu
unctional unitt on a side(Sayy A) can freely 

BHAR
RAT INSTITTUTE OF EN
NGINEERIN
NG AND TEECHNOLOG
GY 
Date: 
Experime ent No.:                                                                                                                                                        47 
 
share 16 rregisters on that side and are other con nnected to the other side(Say B) by a single data buss so 
that registers on side A A can access d data in registeers on other sside. 

Memory 

C6713 DSP has 1) 4KB of direct map
pped Program
m cache 

way set assocciative Data C
2) 4KB 2‐w Cache 

3) 256KB memory 

The 256KB is partitione pped RAM(4‐way set assocciative) and 1
ed into 64KB cache or map 192KB of 
additional mapped RAM. 

To interfaace with the e
external mem
mory it has extternal memorry interface(EEMIF) which p
provides interrface 
to SDRAM M,Flash,SRAM M etc… which ccan address 5
512MB externnal memory sspace.The meemory map is as 
follows 

To transfeer data betweeen any locations in the DSSP’s 32‐bit ad d direct memory 
ddress space aan “Enhanced
access controller (EDMMA)” is provided. EDMA haandles all dataa transfers beetween the L2
2 memory 
controllerr and the periipherals. 

BHAR
RAT INSTITTUTE OF EN
NGINEERIN
NG AND TEECHNOLOG
GY 
Date: 
Experiment No.:                                                                                                                                                        48 
 
On Board Peripherals:‐

1. C6713 DSP has two bidirectional multichannel buffered serial ports(MCBSP0 and MCBSP1) which can                                
operate independently and transfer data from 8 to 32 bit words range. 

2. C6713 DSP has two multichannel audio serial ports (MCASP0 and MCASP1) supported by 16 shift 
registers which may be configured to transmit/receive data. 

3. Two 32 bit timers. 

4. Host Peripheral interface (HPI) which provides a 16 bit interface to host where the host functions as a 
master and can access the entire memory map via EDMA. 

4. Two I2C for control purpose which operate upto 400Kbps. 

5. A Phase Locked Loop (PLL) with a prescaler and four dividers 

6. 16 general purpose input output pins (GPIO) 

This is a brief overall view of C6713 architecture. 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        49 
 
EXECUTING PROGRAMS IN CODE COMPOSER STUDIO 3.0 
 

  To execute program in code composer studio the folliowing steps are followed 

1. Openn “Setup CCS 3” on desktop                                                                        

 
2. In the”Import config select” box select C67XX cycle accurate simulator little endian

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        50 
 
3. Click on import and select Save and Import and select YES to start the code composer studio 3.0

 
4. Click on ProjectÆ New and give a new name to the project

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        51 
 
5. Select FileÆNewÆSource File

 
6. Type your required C program and save the file 
7. Right click on sourceÆAdd  files to projectÆSelect your C file

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        52 
 
8. Right click on libraryÆAdd files to projectÆC6000ÆcgtoolsÆlibÆrts6700.lib

 
9. Right click on sourceÆAdd files to projectÆTutorialÆdsk6713Æhello1ÆSelect linker from 
drop down list box and select ‘hello.cmd’

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        53 
 
10. Goto project select Compile

 
11. Goto project select build

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        54 
 
12. Select FileÆLoad ProgramÆDebugÆProjectname.out

 
13. Goto DebugÆRun

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        55 
 
LINEAR CONVOLUTION 
AIM:‐ 

          To perform linear convolution between two given sequences using Code Composer Studio 3.0 

Apparatus:‐ 

1.  Code Composer Studio 3.0 

2. Windows XP Operating System 

Program:‐ 

#include<stdio.h> 

main() 

static int x[8],h[8]; 

int y[16],z,l1,l2,l3,i,n,k; 

printf("input no of elements in x"); 

scanf("%d", &l1); 

for(i=0;i<l1;i++) 

printf("input %d element",i); 

scanf("%d", &x[i]); 

printf("input no of elements in h"); 

scanf("%d", &l2); 

for(i=0;i<l2;i++) 

printf("input %d element",i); 

scanf("%d", &h[i]); 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        56 
 
l3=l1+l2‐1; 

for(n=0;n<l3;n++) 

y[n]=0; 

z=0; 

for(k=0;(n‐k)>=0;k++) 

z=x[k]*h[n‐k]; 

y[n]=y[n]+z; 

printf("output is = "); 

for(i=0;i<l3;i++) 

printf("%d", y[i]); 

OUTPUT: 

Input no of elements in x4 

Input 0 element1 

Input 1 element2 

Input 2 element3 

Input 3 element4 

Input no of elements in h4 

Input 0 element1 

Input 1 element2 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        57 
 
Input 2 element3 

Input 3 element4 

Output is = 1 4 10 20 25 24 20 

Result:‐ 

              Thus the linear convolution of the given two sequences is found out using code composer studio 
3.0 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        58 
 
CIRCULAR CONVOLUTION 
AIM:‐ 

          To perform circular convolution between two given sequences using and Code Composer Studio 
3.0 

Apparatus:‐ 

1.  Code Composer Studio 3.1 

2. Windows XP Operating System 

Program:‐ 

#include<stdio.h> 

int m,n,x[30],h[30],y[30],i,j, k,x2[30],a[30]; 

void main() 

printf(" enter the length of the first sequence\n"); 

scanf("%d",&m); 

printf(" enter the length of the second sequence\n"); 

scanf("%d",&n); 

printf(" enter the first sequence\n"); 

for(i=0;i<m;i++) 

scanf("%d",&x[i]); 

printf(" enter the second sequence\n"); 

for(j=0;j<n;j++) 

scanf("%d",&h[j]); 

if(m‐n!=0) 

/*If length of both sequences are not equal*/ 

if(m>n) 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        59 
 
/* Pad the smaller sequence with zero*/ 

for(i=n;i<m;i++) 

h[i]=0; 

n=m; 

for(i=m;i<n;i++) 

x[i]=0; 

m=n; 

y[0]=0; 

a[0]=h[0]; 

for(j=1;j<n;j++) 

/*folding h(n) to h(‐n)*/ 

a[j]=h[n‐j]; 

/*Circular convolution*/ 

for(i=0;i<n;i++) 

y[0]+=x[i]*a[i]; for(k=1;k<n;k++) { 

y[k]=0; 

/*circular shift*/ 

for(j=1;j<n;j++) 

x2[j]=a[j‐1]; 

x2[0]=a[n‐1]; 

for(i=0;i<n;i++) 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        60 
 
a[i]=x2[i]; 

y[k]+=x[i]*x2[i]; 

/*displaying the result*/ 

printf(" the circular convolution is\n"); 

for(i=0;i<n;i++) 

printf("%d \t",y[i]); 

OUTPUT: 

Enter the length of the first sequence 

Enter the length of the second sequence 

Enter the first sequence 

Enter the second sequence 

The circular convolution is 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        61 
 
22 

24 

22 

16 

Result:‐ 

              Thus the circular convolution of the given two sequences is found out using code composer 
studio 3.0 

 
 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        62 
 
COMPUTATION OF DFT 
AIM:‐ 

          To compute the DFT of the given sequences using Code Composer Studio Software 3.0 

Apparatus:‐ 

1.  Code Composer Studio 3.0 

2. Windows XP Operating System 

Program:‐ 

#include<stdio.h> 

#include<math.h> 

main() 

float x[8],re[8],img[8],q,resum,imsum,coss,sins; 

int len,i,j,k; 

printf("enter the no of elements"); 

scanf("%d", &len); 

for(i=0;i<len;i++) 

printf("enter %d element", i); 

scanf("%f", &x[i]); 

for(i=0;i<len;i++) 

resum=0; 

imsum=0; 

for(k=0;k<len;k++) 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 
Date: 
Experiment No.:                                                                                                                                                        63 
 

q=((2.0*k*3.14*i)/len); 

coss=cos(q); 

sins=sin(q); 

resum=resum+x[k]*coss; 

imsum=imsum+x[k]*sins; 

re[i]=resum; 

img[i]=imsum; 

for(j=0;j<len;j++) 

printf(" %f+j%f", re[j],img[j]); 

 } 

OUTPUT: 

Enter the no of elements3 

Enter 0 element2 

Enter 1 element3 

Enter 2 element5 

10.000000+j0.000000 ‐2.006431+j‐1.725140 ‐1.987100+j1.745822 

Result:‐ 

             Thus the DFT of the given sequence is found using Code Composer Studio3.0 

BHARAT INSTITUTE OF ENGINEERING AND TECHNOLOGY 

S-ar putea să vă placă și