You are on page 1of 51

1

EXPERIMENT-1
OBJECTIVE: Introduction to MATLAB software and about its working environment. SOFTWARE REQUIRED:- MATLAB 2006b THEORY: 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 notations. 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 graphical user interface 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 non-interactive 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 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 technologies. 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.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

About Matrices
In the MATLAB environment, a matrix is a rectangular array of numbers. Special meaning is sometimes attached to 1-by-1 matrices, which are scalars, and to matrices with only one row or column, which are vectors. MATLAB has other ways of storing both numeric and nonnumeric data, but in the beginning, it is usually best to think of everything as a matrix. The operations in MATLAB are designed to be as natural as possible. Where other programming languages work with numbers one at a time, MATLAB allows you to work with entire matrices quickly and easily.

Entering Matrices
The best way for you to get started with MATLAB is to learn how to handle matrices. Start MATLAB and follow along with each example. You can enter matrices into MATLAB in several different ways:

Enter an explicit list of elements. Load matrices from external data files. Generate matrices using built-in functions. Create matrices with your own functions in M-files.

Start by entering matrix as a list of its elements. You only have to follow a few basic conventions:

Separate the elements of a row with blanks or commas. Use a semicolon,; , to indicate the end of each row. Surround the entire list of elements with square brackets, [ ].

To enter matrix, simply type in the Command Window A = [16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1] MATLAB displays the matrix you just entered: A= 16 5 9 4 3 10 6 15 2 11 7 14 13 8 12 1

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

Sum, Transpose, and Diag


You are probably already aware that the special properties of a magic square have to do with the various ways of summing its elements. If you take the sum along any row or column, or along either of the two main diagonals, you will always get the same number. Let us verify that using MATLAB. The first statement to try is sum(A) MATLAB replies with ans = 34 34 34 34

When you do not specify an output variable, MATLAB uses the variable ans, short for answer, to store the results of a calculation. You have computed a row vector containing the sums of the columns of A. Each of the columns has the same sum, the magic sum, 34. How about the row sums? MATLAB has a preference for working with the columns of a matrix, so one way to get the row sums is to transpose the matrix, compute the column sums of the transpose, and then transpose the result. For an additional way that avoids the double transpose; use the dimension argument for the sum function. MATLAB has two transpose operators. The apostrophe operator (e.g., A') performs a complex conjugate transposition. It flips a matrix about its main diagonal, and also changes the sign of the imaginary component of any complex elements of the matrix. The dot-apostrophe operator (e.g., A.'), transposes without affecting the sign of complex elements. For matrices containing all real elements, the two operators return the same result. So A' produces ans = 16 3 2 13 and 5 10 11 8 9 6 7 12 4 15 14 1

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

sum(A')' produces a column vector containing the row sums ans = 34 34 34 34 The sum of the elements on the main diagonal is obtained with the sum and the diag functions: diag(A) produces ans = 16 10 7 1 and sum(diag(A)) produces ans = 34 The other diagonal, the so-called antidiagonal, is not so important mathematically, so MATLAB does not have a ready-made function for it. But a function originally intended for use in graphics, fliplr, flips a matrix from left to right: sum(diag(fliplr(A))) ans = 34

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

The Colon Operator


The colon, :, is one of the most important MATLAB operators. It occurs in several different forms. The expression 1:10 is a row vector containing the integers from 1 to 10: 1 2 3 4 5 6 7 8 9 10

To obtain nonunit spacing, specify an increment. For example, 100:-7:50 is 100 and 0:pi/4:pi is 0 0.7854 1.5708 2.3562 3.1416 93 86 79 72 65 58 51

Subscript expressions involving colons refer to portions of a matrix: A(1:k,j) is the first k elements of the jth column of A. Thus: sum(A(1:4,4)) computes the sum of the fourth column. However, there is a better way to perform this computation. The colon by itself refers to all the elements in a row or column of a matrix and the keyword end refers to the last row or column. Thus: sum(A(:,end)) computes the sum of the elements in the last column of A: ans = 34 Why is the magic sum for a 4-by-4 square equal to 34? If the integers from 1 to 16 are sorted into four groups with equal sums, that sum must be

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

sum(1:16)/4 which, of course, is ans = 34

Operators
Expressions use familiar arithmetic operators and precedence rules. + Addition Subtraction

* Multiplication / \ Division Left division

^ Power ' ( ) Complex conjugate transpose Specify evaluation order

Functions
MATLAB provides a large number of standard elementary mathematical functions, including abs, sqrt, exp, and sin. Taking the square root or logarithm of a negative number is not an error; the appropriate complex result is produced automatically. MATLAB also provides many more advanced mathematical functions, including Bessel and gamma functions. Most of these functions accept complex arguments. For a list of the elementary mathematical functions, type helpelfun For a list of more advanced mathematical and matrix functions, type helpspecfun helpelmat Some of the functions, like sqrt and sin, are built in. Built-in functions are part of the MATLAB core so they are very efficient, but the computational details are not readily accessible. Other functions, like gamma and sinh, are implemented in M-files.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

There are some differences between built-in functions and other functions. For example, for built-in functions, you cannot see the code. For other functions, you can see the code and even modify it if you want. Several special functions provide values of useful constants. pi i j eps 3.14159265... Imaginary unit, Same as i Floating-point relative precision,

realmin Smallest floating-point number, realmax Largest floating-point number,

Inf NaN

Infinity Not-a-number

Infinity is generated by dividing a nonzero value by zero, or by evaluating well defined mathematical expressions that overflow, i.e., exceed realmax. Not-a-number is generated by trying to evaluate expressions like 0/0 or Inf-Inf that do not have well defined mathematical values. The function names are not reserved. It is possible to overwrite any of them with a new variable, such as eps = 1.e-6 and then use that value in subsequent calculations. The original function can be restored with cleareps

RESULT: Introduction to MATLAB and its working environment has been done with
examples.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

VIVA-VOCE
Que.-1. MATLAB stands for?

Ans. Matrix Laboratory. Que.-2. What is MATLAB? Ans. 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 notations. Que.-3. What is the output of linspace(2,10, 2)?

Ans. [2 4 6 8 10] Que.-4. What is the output of 1:2:10? Ans. [1 3 5 7 9] Que.-5. What is the function of semicolon in MATLAB? Ans. To suppress the output from command window.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

EXPERIMENT-2
OBJECTIVE: Write a MATLAB program to find the sum of all the elements of a given Matrix. SOFTWARE REQUIRED:- MATLAB 2006b THEORY:
In the MATLAB environment, a matrix is a rectangular array of numbers. Special meaning is sometimes attached to 1-by-1 matrices, which are scalars, and to matrices with only one row or column, which are vectors.MATLAB has other ways of storing both numeric and nonnumeric data, but in the beginning, it is usually best to think of everything as a matrix. The operations in MATLAB are designed to be as natural as possible. Where other programming languages work with numbers one at a time, MATLAB allows you to work with entire matrices quickly and easily.If the matrix entered by the user is as follows A = [1 2 3; 4 6 8] Then you have to write a general program which calculates sum of all its elements i.e. 1, 2,3,4,6 & 8; which is in this particular case is 24.

PROGRAM:
clc; clearall; closeall; a= input(enter the matrix); d=size(a); sum=0; fori=1:1:d(1) fori=1:1:d(2) sum=sum+a(i,j); end end sum

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

10

RESULT:
enter the matrix[1 23;4 6 8] sum=24

VIVA-VOCE
Que.-1. What is the output of size(A); where A=[2 4 3; 5 6 7]? Ans. [2 3]; it returns the number of rows and number of columns of a given matrix.

Que.-2. What is the function of close all in given program? Ans. Que.-3. Ans. It closes all the figure windows already opened in previous results. What do you mean by matrix? Matrix is a rectangular array of numbers.

Que.-4. What is the function of clc? Ans. clc- clear command window.

Que.-5. What is the function of clear all? Ans. clear all- clear workspace; means clear all the variables defined previously.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

11

EXPERIMENT-3
OBJECTIVE: Write a MATLAB program to plot the following Continuous time and discrete time signals. 1. Unit Step Function 2. Unit Impulse Function 3. Unit Ramp Function 4. Sine Function 5. Exponential Function SOFTWARE REQUIRED:- MATLAB 2006b THEORY:
A continuous signal or a continuous-time signal is a varying quantity (a signal) whose domain, which is often time, is a continuum (e.g., a connected interval of the real numbers). That is, the function's domain is an uncountable set. The function itself need not be continuous. To contrast, a discrete time signal has a countable domain, like the natural numbers. A signal of continuous amplitude and time is known as a continuous time signal or an analog signal. This (a signal) will have some value at every instant of time. The electrical signals derived in proportion with the physical quantities such as temperature, pressure, sound etc. are generally continuous signals. The other examples of continuous signals are sine wave, cosine wave, triangular wave etc. The signal is defined over a domain, which may or may not be finite, and there is a functional mapping from the domain to the value of the signal. The continuity of the time variable, in connection with the law of density of real numbers, means that the signal value can be found at any arbitrary point in time. A discrete signal or discrete-time signal is a time series consisting of a sequence of qualities. In other words, it is a type series that is a function over a domain of discrete integral. Unlike a continuous-time signal, a discrete-time signal is not a function of a continuous argument; however, it may have been obtained by sampling from a continuous-time signal, and then each value in the sequence is called a sample. When a discrete-time signal obtained by sampling a sequence corresponding to uniformly spaced times, it has an associated sampling rate; the sampling rate is not apparent in the data sequence, and so needs to be associated as a separate data item.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

12

Figure 3.1: Continuous-Time Vs Discrete time signal.

Figure 3.2: Unit Step Function.

Figure 3.3: Unit Impulse Function.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

13

Figure 3.4: Unit Ramp function.

Figure 3.5: Sinusoidal Function.

Figure 3.6 : Exponential Function.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

14

PROGRAM:
clc; clear all; close all; t= linspace(-50,50,201); %% function definition fori=1:1:201 if t(i)< 0 f1(i)=0; else f1(i)=1; end end fori=1:1:201 if t(i)== 0 f2(i)=1; else f2(i)=0; end f3(i)=sin(t(i)); f4(i)=exp(t(i)); if t(i)<=0 f5(i)=0; else f5(i)=t(i); end end %% Continuos plots subplot(5,1,1) plot(t,f1) xlabel('time') ylabel('amplitude') title('unit step function') subplot(5,1,2) plot(t,f2) xlabel('time') ylabel('amplitude') title('unit impulse function') subplot(5,1,3) plot(t,f3) xlabel('time') ylabel('amplitude') title('sine function') subplot(5,1,4)

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

15

plot(t,f4) xlabel('time') ylabel('amplitude') title('exponential function') subplot(5,1,5) plot(t,f5) xlabel('time') ylabel('amplitude') title('unit ramp function') %% Discrete plots figure(2) subplot(5,1,1) stem(t,f1) xlabel('time') ylabel('amplitude') title('unit step function') subplot(5,1,2) stem(t,f2) xlabel('time') ylabel('amplitude') title('unit impulse function') subplot(5,1,3) stem(t,f3) xlabel('time') ylabel('amplitude') title('sine function') subplot(5,1,4) stem(t,f4) xlabel('time') ylabel('amplitude') title('exponential function') subplot(5,1,5) stem(t,f5) xlabel('time') ylabel('amplitude') title('unit ramp function')

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

16

RESULT:
unit s tep func tion 1 am plitude 0.5 0 -50 -40 -30 -20 -10 0 tim e unit im pulse func tion 10 20 30 40 50

1 am plitude 0.5 0 -50 -40 -30 -20 -10 0 tim e sine func tion 10 20 30 40 50

1 am plitude 0 -1 -50 x 10
21

-40

-30

-20

-10

0 tim e exponential function

10

20

30

40

50

10 am plitude 5

0 -50

-40

-30

-20

-10

0 tim e unit ram p func tion

10

20

30

40

50

50 am plitude

0 -50

-40

-30

-20

-10

0 tim e

10

20

30

40

50

u n it s te p fu n c tio n 1 a m p litu d e 0 .5 0 -5 0 -4 0 -3 0 -2 0 -1 0 0 tim e u n it im p u ls e fu n c tio n 10 20 30 40 50

1 a m p litu d e 0 .5 0 -5 0 -4 0 -3 0 -2 0 -1 0 0 tim e s in e fu n c tio n 10 20 30 40 50

1 a m p litu d e 0 -1 -5 0 x 10
21

-4 0

-3 0

-2 0

-1 0

0 tim e e x p o n e n tia l fu n c tio n

10

20

30

40

50

10 a m p litu d e 5

0 -5 0

-4 0

-3 0

-2 0

-1 0

0 tim e u n it ra m p fu n c tio n

10

20

30

40

50

50 a m p litu d e

0 -5 0

-4 0

-3 0

-2 0

-1 0

0 tim e

10

20

30

40

50

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

17

VIVA-VOCE
Que.-1. What do you mean by continuous time signal? Ans. A continuous signal or a continuous-time signal is a varying quantity (a signal) whose domain, which is often time, is a continuum (e.g., a connected interval of the real numbers). Que.-2. What do you mean by discrete-time signal? Ans. A discrete signal or discrete-time signal is a time series consisting of a sequence of qualities. Que.-3. What do you mean by analog signal? Ans. Analog signal is the continuous-time signal which has continuous amplitude. Que.-4. What do you mean by digital signal? Ans. Digital signal is the discrete-time signal which has discrete amplitude. Que.-5. By what means, a continuous-time signal is converted into discrete-time signal? Ans. Sampling.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

18

EXPERIMENT-4
OBJECTIVE: Write a MATLAB program to plot the basic transformation (amplitude scaling, time scaling, time-shifting& time-reversal) of the CT signals. SOFTWARE REQUIRED:- MATLAB 2006b THEORY:
Signal Operations are simply modifications to the time variable of the signal to generate new signals. These are pretty similar to the mathematical graphical transformations from our good old Calculus text.The three kinds of Signal Operations are Time Shifting, Time Scaling & Time Inversion(or Time Reversal). Time Shifting is simply shifting the signal in time. When we add a constant to the time, we obtain the advanced signal, & when we decrease the time, we get the delayed signal.

Time Scaling is compressing or dilating the signal.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

19

Time Inversion is simply flipping the signal about the y-axis.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

20

Amplitude Shifting

PROGRAM:
clc; clear all; close all; t= linspace(-10,10,1000); %% function definition fori=1:1:1000 if (t(i)> -1)&& (t(i)<2) f(i)=1; else f(i)=0; end end subplot(5,1,1) plot(t,f) axis([-10,10,-2,2]) grid on xlabel('time') ylabel('f(t)') title('original function') subplot(5,1,2) plot(t,10*f) axis([-10,10,-2,12]) grid on xlabel('time') ylabel('10f(t)') title('amplitude scaled function')

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

21

fori=1:1:1000 if ((t(i)-3)> -1)&& ((t(i)-3)<2) f1(i)=1; else f1(i)=0; end end subplot(5,1,3) plot(t,f1) axis([-10,10,-2,2]) grid on xlabel('time') ylabel('f(t-3)') title('time delayed function') fori=1:1:1000 if (-t(i)>-1)&& (-t(i)<2) f2(i)=1; else f2(i)=0; end end subplot(5,1,4) plot(t,f2) axis([-10,10,-2,2]) grid on xlabel('time') ylabel('f(-t)') title('time reversed function') fori=1:1:1000 if (t(i)/2>-1)&& (t(i)/2<2) f3(i)=1; else f3(i)=0; end end subplot(5,1,5) plot(t,f3) axis([-10,10,-2,2]) grid on xlabel('time') ylabel('f(t/2)') title('time scaled function')

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

22

RESULT:

o ri g i n a l f u n c ti o n 2 0 f(t) -2 -1 0 -8 -6 -4 -2 0 ti m e a m p l i t u d e s c a l e d f u n c ti o n 10 5 0 -1 0 2 4 6 8 10

1 0 f(t)

-8

-6

-4

-2

0 ti m e ti m e d e l a y e d f u n c ti o n

10

2 0 f(t-3 ) -2 -1 0 -8 -6 -4 -2 0 ti m e ti m e re ve rs e d f u n c ti o n 2 0 f(-t) -2 -1 0 -8 -6 -4 -2 0 ti m e ti m e s c a l e d f u n c ti o n 2 0 f(t/2 ) -2 -1 0 -8 -6 -4 -2 0 ti m e 2 4 6 8 10 2 4 6 8 10 2 4 6 8 10

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

23

VIVA-VOCE

Que.-1. What do you mean by time delayed signal? Ans. When we decrease the time, we get the delayed signal i.e. x(t-t0), where t0>0. Que.-2. What do you mean by time advanced signal? Ans. When we increase the time, we get the time advanced signal i.e. x(t+t0), where t0>0. Que.-3. What do you mean by time scaling? Ans. Ans. Ans. Time Scaling is compressing or dilating the signal. Time Inversion is simply flipping the signal about the y-axis. Amplitude scaling means simply amplifying or attenuating the signal amplitude.

Que.-4. What do mean by time inversion? Que.-5. What do you mean by amplitude scaling?

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

24

EXPERIMENT-5
OBJECTIVE: Write a MATLAB program to find linear convolution of two given sequences. SOFTWARE REQUIRED:- MATLAB 2006b THEORY:
In mathematics and, in particular, functional analysis, convolution is a mathematical operation on two functions f and g, producing a third function that is typically viewed as a modified version of one of the original functions, giving the area overlap between the two functions as a function of the amount that one of the original functions is translated. Convolution is similar to cross-correlation. It has applications that include probability, statistics, computer vision, image and signal processing, electrical engineering, and differential equations. The convolution of f and g is written fg, using an asterisk or star. It is defined as the integral of the product of the two functions after one is reversed and shifted. As such, it is a particular kind of integral transform:

(commutativity)

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

25

PROGRAM:
clc; clearall; closeall; x1=[1,7,8,9,4,9,-8,7]; x2=[2,3,5,1,4,9,4,0,6]; y=conv(x1,x2); subplot(3,1,1) stem(x1) xlabel('time') ylabel('amplitude') title('first sequence') subplot(3,1,2) stem(x2) xlabel('time') ylabel('amplitude') title('second sequence') subplot(3,1,3) stem(y) xlabel('time') ylabel('amplitude') title('convoluted sequence')

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

26

RESULT:

firs t s e q u e n c e 10 5 a m p litu d e 0 -5 -1 0

4 tim e second sequence

10

a m p litu d e

5 tim e c o n vo lu te d s e q u e n c e

200

100 a m p litu d e

-1 0 0

8 tim e

10

12

14

16

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

27

VIVA-VOCE
Que.-1. What is the physical significance of convolution? Ans. Convolution is a mathematical operation on two functions f and g, producing a third function that is typically viewed as a modified version of one of the original functions, giving the area overlap between the two functions as a function of the amount that one of the original functions is translated. Que.-2. What is the physical significance of cross-correlation? Ans. Cross-correlation gives the similarity between two different signals.

Que.-3. What is the physical significance of Auto-correlation? Ans. Auto-correlation gives the similarity between the original signal and its time delayed version. Que.-4. Is Convolution function commutative or not in nature? Ans. yes. Que.-5. What is the response of the system having unit impulse response h(t) and input f(t)? Ans. y(t)=f(t)*h(t); where * denotes convolution.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

28

EXPERIMENT-6
OBJECTIVE: Write a MATLAB program to plot the following Continuous timeTrigonometric Fourier series. SOFTWARE REQUIRED:- MATLAB 2006b THEORY:
In mathematics, a Fourier series decomposes periodic functions or periodic signals into the sum of a (possibly infinite) set of simple oscillating functions, namely sines and cosines (or complex exponentials). The study of Fourier series is a branch of Fourier analysis. The Fourier series is named in honour of Jean-Baptiste Joseph Fourier (17681830), who made important contributions to the study of trigonometric series, after preliminary investigations by Leonhard Euler, Jean le Rondd'Alembert, and Daniel Bernoulli. In this section, f(x) denotes a function of the real variable x. This function is usually taken to be periodic, of period 2, which is to say that f(x + 2) = f(x), for all real numbers x. We will attempt to write such a function as an infinite sum, or series of simpler 2periodic functions. We will start by using an infinite sum of sine and cosine functions on the interval [, ], as Fourier did (see the quote above), and we will then discuss different formulations and generalizations. Fourier's formula for 2-periodic functions using sines and cosines Fourier analysis relates the function's time domain, to the function's frequency domain. The component frequencies, spread across the frequency spectrum, are represented as peaks in the frequency domain.

For a periodic function f(x) that is integrable on [, ], the numbers

are called the Fourier coefficients of f.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

29

PROGRAM:
clc; clearall; closeall; T=4; t= linspace(-2,2,10000); fori=1:1:10000 if t(i)>-2&& t(i)<-1 f(i)=-1; elseif t(i)>-1&& t(i)<1 f(i)=1; else f(i)=-1; end end a0=0; fori=1:1:10000 a0=a0+(f(i)*T/9999)/T; end for n=1:1:2000 s1=0; s2=0; fori=1:1:10000 s1=s1+(f(i)*cos(n*2*pi*t(i)/T)*T/9999); s2=s2+(f(i)*sin(n*2*pi*t(i)/T)*T/9999); end a(n)=(s1*2)/T; b(n)=(s2*2)/T; end fori=1:1:10000 sum=0; for n=1:1:2000 sum=sum+a(n)*cos(n*2*pi*t(i)/T)+b(n)*sin(n*2*pi*t(i)/T); end g(i)=a0+sum; end plot(t,g) xlabel('time') ylabel('amplitude') title('TFS')

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

30

RESULT:
TFS 1.5

0.5

0 amplitude -0.5 -1 -1.5 -2 -2

-1.5

-1

-0.5

0 time

0.5

1.5

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

31

VIVA-VOCE

Que.-1. What is the role of fourier series in mathematics? Ans. In mathematics, a Fourier series decomposes periodic functions or periodic signals into the sum of a (possibly infinite) set of simple oscillating functions, namely sines and cosines (or complex exponentials). Que.-2. What is mathematical formulation of trigonometric fourier series?

Ans. Que.-3. How do fourier series relate with fourier transform? Ans. Fourier series becomes fourier transform when T=infinite; i.e. periodic signal becomes aperiodic. Que.-4. Define fourier coefficients of trigonomentricfourier series? Ans.

Que.-5. Is fourier series linear or not? Ans. Linear.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

32

EXPERIMENT-7
OBJECTIVE: Write a MATLAB program to find Fourier transform of a given unit impulse signal. SOFTWARE REQUIRED:- MATLAB 2006b THEORY:
The Fourier transform, named after Joseph Fourier, is a mathematical transform with many applications in physics and engineering. Very commonly it transforms a mathematical function of time, f(t), into a new function, sometimes denoted by F, whose argument is frequency with units of cycles/s (hertz) or radians per second. The new function is then known as the Fourier transform and/or the frequency spectrum of the function f. The Fourier transform is also a reversible operation. Thus, given the function F, one can determine the original function, f. (See Fourier inversion theorem.) f and F are also respectively known as time domain and frequency domain representations of the same "event". Most often perhaps, f is a real-valued function, and F is complex valued, where a complex number describes both the amplitude and phase of a corresponding frequency component. In general, f is also complex, such as the analytic representation of a real-valued function. The term "Fourier transform" refers to both the transform operation and to the complex-valued function it produces. In the case of a periodic function (for example, a continuous but not necessarily sinusoidal musical sound), the Fourier transform can be simplified to the calculation of a discrete set of complex amplitudes, called Fourier series coefficients.
,

PROGRAM:
clc; clearall; closeall; t=linspace(-50,50,101); w=linspace(-50,50,101); for l=1:101 if t(l)==0 x(l)=1; else x(l)=0; end end

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

33

subplot(2,1,1) plot(t,x) xlabel('time') ylabel('x(t)') title('Time-domain signal') i=sqrt(-1); for j=1:1:101 sum=0; for k=1:1:101 sum=sum+x(k)*exp(-i*w(j)*t(k)); end X(j)=sum; end subplot(2,1,2) plot(w,X) xlabel('frequency') ylabel('X(w)') title('Frequency-domain signal')

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

34

RESULT:
Tim e -d o m a in s ig n a l 1 0 .8 0 .6 x (t) 0 .4 0 .2 0 -5 0

-4 0

-3 0

-2 0

-1 0

0 tim e F re q u e n c y -d o m a in s ig n a l

10

20

30

40

50

1 .5

X (w )

0 .5

0 -5 0

-4 0

-3 0

-2 0

-1 0

0 fre q u e n c y

10

20

30

40

50

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

35

VIVA-VOCE

Que.-1. What is fourier transform? Ans. It transforms a mathematical function of time, f(t), into a new function, sometimes denoted by F, whose argument is frequency with units of cycles/s (hertz) or radians per second. Que.-2. What is duality property in fourier transform? Ans. If F(f(t))=F(w); Then; F(F(t))=f(-t). Que-3. Is fourier transform linear or not? Ans. Linear.

Que.-4. What is mathematical formulation of fourier transform? Ans.

Que.-5. What is mathematical formulation of inverse fourier transform? Ans.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

36

EXPERIMENT-8
OBJECTIVE: Write a MATLAB program to find Z-transform of a given unit impulse signal. SOFTWARE REQUIRED:- MATLAB 2006b THEORY:
In mathematics and signal processing, the Z-transform converts a time domain signal, which is a sequence of real or complex numbers, into a complex frequency domain representation.It can be considered as a discrete-time equivalent of the Laplace transform. Z-transform is reversible in nature.

The region of convergence (ROC) is the set of points in the complex plane for which the Ztransform summation converges.

PROGRAM:
clc; clearall; closeall; n=linspace(-50,50,101); w=linspace(-50,50,101); i=sqrt(-1); z=exp(i*w); for l=1:101 if n(l)==0 x(l)=1; else x(l)=0; end end

subplot(2,1,1)

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

37

stem(n,x) xlabel('time') ylabel('x(t)') title('Time-domain signal') for j=1:1:101 sum=0; for k=1:1:101 sum=sum+x(k)*(z(j))^(-n(k)); end X(j)=sum; end subplot(2,1,2) plot(w,X) xlabel('frequency') ylabel('X(z)') title('Z-domain signal')

RESULT: Mr. Umesh Sharma PREPARED BY Dr. Sanjay Sharma HOD,(ECE)

38

T im e -d o m a in s ig n a l 1 0 .8 0 .6 x (t) 0 .4 0 .2 0 -5 0

-4 0

-3 0

-2 0

-1 0

0 tim e Z -d o m a in s ig n a l

10

20

30

40

50

1 .5

X (z )

0 .5

0 -5 0

-4 0

-3 0

-2 0

-1 0

0 fre q u e n c y

10

20

30

40

50

VIVA-VOCE Mr. Umesh Sharma PREPARED BY Dr. Sanjay Sharma HOD,(ECE)

39

Que.-1. What is Z- transform? Ans. In mathematics and signal processing, the Z-transform converts a time domain signal, which is a sequence of real or complex numbers, into a complex frequency domain representation. Que.-2. What is ROC? Ans. The region of convergence (ROC) is the set of points in the complex plane for which the Z-transform summation converges.

Que-3. How do Z-transform relate with Laplace transform? Ans. It can be considered as a discrete-time equivalent of the Laplace transform.

Que.-4. What is mathematical formulation of Z-transform? Ans.

Que.-5. What is mathematical formulation of inverse Z-transform? Ans.

EXPERIMENT-9
Mr. Umesh Sharma PREPARED BY Dr. Sanjay Sharma HOD,(ECE)

40

OBJECTIVE: To model a system in simulink that amplifies a sine wave bya factor two. SOFTWARE REQUIRED:- MATLAB 2006b THEORY:
In electronics, gain is a measure of the ability of a circuit (often an amplifier) to increase the power or amplitude of a signal from the input to the output, by adding energy to the signal converted from some power supply. It is usually defined as the mean ratio of the signal output of a system to the signal input of the same system. It is often expressed using the logarithmic decibel (dB) units ("dB gain"). A gain greater than one (zero dB), that is, amplification, is the defining property of an active component or circuit, while a passive circuit will have a gain of less than one.The term gain on its own is ambiguous, and can refer to the ratio of output to input voltage, (voltage gain), current (current gain) or electric power (power gain).

Simulink Model:

Sine Wave

Gain

Scope1

Scope

RESULT:

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

41

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

42

VIVA-VOCE

Que.-1. What is linear gain? Ans. It is usually defined as the mean ratio of the signal output of a system to the signal input of the same system. Que.-2. What is value of gain in case of active elements? Ans. Greater than one Que.-3. What is value of gain in case of passive elements? Ans. Less than one. Que.-4. What is mathematical formulation of power gain in dB? Ans.

Que.-5. What is mathematical formulation of voltage and current gain in dB? Ans.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

43

EXPERIMENT-10
OBJECTIVE: To check linearity property of the system using simulink. SOFTWARE REQUIRED:- MATLAB 2006b THEORY:
In mathematics, a linear map or linear function f(x) is a function which satisfies the following two properties: Additivity (also called the superposition property): f(x + y) = f(x) + f(y). Homogeneity of degree 1: f(x) = f(x)for all . It can be shown that additivity implies the homogeneity in all cases where is rational; this is done by proving the case where is a natural number by mathematical induction and then extending the result to arbitrary rational numbers. If f is assumed to be continuous as well then this can be extended to show that homogeneity for any real number, using the fact that rationalsform a dense subset of the real numbers.

Model 1:

S c o p e

2 S in eW a v e 1 G a in

S c o p e 2

S in eW a v e

S c o p e 1

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

44

Model2:

S c o p e

2 G a i n S in eW a v e 1

S c o p e 2

2 G a in 1 S in e W a v e

S c o p e 1

RESULT: Linearity property has been verified. For Model-1

FOR MODEL-2

VIVA-VOCE Mr. Umesh Sharma PREPARED BY Dr. Sanjay Sharma HOD,(ECE)

45

Que.-1. What is linear function? Ans. Linear function f(x) is a function which satisfies additivity and homogeneity properties..

Que.-2. What is additivity? Ans. Additivity (also called the superposition property): f(x + y) = f(x) + f(y).

Que.-3. What is homogeneity? Ans. Homogeneity of degree 1: f(x) = f(x)for all .

Que.-4. What is linearity? Ans. f(ax + by) = af(x) + bf(y).

Que.-5. What is response of the CT LTI system having impulse response h(t) and input f(t)? Ans. f(t)*h(t); where * denotes convolution.

EXPERIMENT NO:-11 (BS)


Mr. Umesh Sharma PREPARED BY Dr. Sanjay Sharma HOD,(ECE)

46

OBJECTIVE :- Write a MATLAB program to study the circulate convolution SOFTWARE REQUIRED:- MATLAB 2006b THEORY:
The circular convolution, also known as cyclic convolution, of two aperiodic functions (i.e. Schwartz functions) occurs when one of them is convolved in the normal way with a periodic summation of the other function. That situation arises in the context of the Circular convolution theorem. The identical operation can also be expressed in terms of the periodic summations of both functions, if the infinite integration interval is reduced to just one period. That situation arises in the context of the discrete-time Fourier transform (DTFT) and is also called periodic convolution. In particular, the DTFT of the product of two discrete sequences is the periodic convolution of the DTFTs of the individual sequences.[1] Let x be a function with a well-defined periodic summation, xT, where:

If h is any other function for which the convolution xT h exists, then the convolution xT h is periodic and identical to:

[2]

where to is an arbitrary parameter and hT is a periodic summation of h.

PROGRAM:clear all; x=input('enter the first sequence'); h=input('enter the s second sequence'); N1=length(x) N2=length(h) N=max(N1,N2)

y=cconv(x,h,N) n=0:1:N1-1;

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

47

subplot(2,2,1) stem(n,x) xlabel('n'); ylabel('x(n)'); n=0:1:N2-1; subplot(2,2,2) stem(n,h) xlabel('n'); ylabel('h(n)'); n=0:1:N-1; subplot(2,2,3) stem(n,y) xlabel('n'); ylabel('y(n)'); title('circular convolution is given as');

RESULT

VIVA-VOCE Mr. Umesh Sharma PREPARED BY Dr. Sanjay Sharma HOD,(ECE)

48

Q1:- Why the name Circular is given to circular convolution? Ans:-The shift in circular convolution are circular in nature. Q2:- Write an equation for circular convolution. N=1 Ans:- x3(m) = x1(n)x2((m-n))N m=0,1,2,N-1 N=0 Q3:- What is the difference between circular convolution and linear convolution? Ans:- 1. Shift are linear in linear convolution, whereas they are circular in circular Convolution. 2. Convolved sequence is of length N + M -1 in linear convolution, but it is N in Circular Convolution. Q4:- Can you implement linear convolution using circular convolution? Ans:- Yes, But circular convolution cannot be implemented using linear convolution. Q5:- Is it possible to implement filtering operation using circular convolution ? Ans:- Yes, filtering operation is implemented using linear convolution and linear convolution can be implement using circular convolution.

EXPERIMENT NO:-12 (BS) Mr. Umesh Sharma PREPARED BY Dr. Sanjay Sharma HOD,(ECE)

49

OBJECTIVE :- Generate an ASK wave form for transmitting the digital data of the given bit sequence. SOFTWARE REQUIRED:- MATLAB 2006b THEORY:
Amplitude-shift keying (ASK) is a form of amplitude modulation that represents digital data as variations in the amplitude of a carrier wave. Any digital modulation scheme uses a finite number of distinct signals to represent digital data. ASK uses a finite number of amplitudes, each assigned a unique pattern of binary digits. Usually, each amplitude encodes an equal number of bits. Each pattern of bits forms the symbol that is represented by the particular amplitude. The demodulator, which is designed specifically for the symbol-set used by the modulator, determines the amplitude of the received signal and maps it back to the symbol it represents, thus recovering the original data. Frequency and phase of the carrier are kept constant.

PROGRAM:clear all ; close all; fc=20; g=[1 1 0 0 1 1 1 0 1 0 0 0 1]; n=1; while(n<=length(g)) if g(n)==0 tx=((n-1)*0.1: .1/100: n*.1); p=0 plot(tx,p); hold on; else tx=((n-1)*0.1: .1/100 :n*.1) p=(1)*sin(2*pi*fc*tx) plot(tx,p); hold on; end n=n+1; end

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)

50

RESULT
AMPLITUDE

TIME

VIVA-VOCE Mr. Umesh Sharma PREPARED BY Dr. Sanjay Sharma HOD,(ECE)

51

Q1:-What is purpose of various windows ? Ans:- The window are selected depending upon the transition width of main lobe and Amplitudes of side lobes. The windows are selected such that Gibbs phenomenon is reduced. Q2:- What are desirable characteristics of window ? Ans.:- 1. The window must have narrow main lobe. 2. Amplitudes of side lobes must be negligible. Q3:- Whether all the windows are symmetric? Why? Ans:-All the windows are symmetric, since linear phase filter need symmetric impulse response. Q4:- How the window is selected ? Ans:- The particular window is selected depending upon minimum stop band attenuation.

Mr. Umesh Sharma PREPARED BY

Dr. Sanjay Sharma HOD,(ECE)