You are on page 1of 22

EXPERIMENT -1

AIM: - Write a Matlab code to generate different types of basic Signals.

THEORY- A signal as referred to in communication systems, signal processing,


and electrical engineering "is a function that conveys information about the behavior or attributes
of some phenomenon".There are different types of signals like:

1.Sine wave-The sine wave or sinusoid is a mathematical curve that describes a smooth
repetitive oscillation.The signal repeats itself after a period of 2pi. Its most basic form as a
function of time (t) is:

The sine function attains maximum value of 1 at angles (n+i)pi/2 and value 0 at n*pi.

2.Cosine wave- A cosine wave is a signal waveform with a shape identical to that of a sine
wave , except each point on the cosine wave occurs exactly 1/4 cycle earlier than the
corresponding point on the sine wave. A cosine wave and its corresponding sine wave have the
same frequency, but the cosine wave leads the sine wave by 90 degrees of phase .
3.Exponential signal-A real exponential signal is defined as

Where both "A" and "" are real. Depending on the value of "" the signals will be different.
If "" is positive the signal x(t) is a growing exponential and if "" is negative then the
signal x(t) is a decaying exponential. For =0, signal x(t) will be constant.

4.Impulse signal-The Dirac delta function or unit impulse or often referred to as the delta
function, is the function that defines the idea of a unit impulse in continuous-time. Informally,
this function is one that is infinitesimally narrow, infinitely tall, yet integrates to one. Perhaps the
simplest way to visualize this as a rectangular pulse from a -D/2 to a +D/2 with a height of 1/D.
As we take the limit of this setup as D approaches 0, we see that the width tends to zero and the
height tends to infinity as the total area remains
constant at one.
The impulse function is often written as

If the magnitude at 0 is 1 unit then the function is termed as unit impulse function.
5.Unit step function-The Heaviside step function, or the unit step function, usually denoted
by H (but sometimes u or ), is adiscontinuous function whose value is zero for negative
argument and one for positive argument.
An alternative form of the unit step, as a function of a discrete variable n:

6.Ramp functionThe ramp function (


definition is:

) may be defined analytically in several ways. Possible

It has a value 0 for x<0 and a value r(x)=x for positive x. Thus forming a line with slope 1 for
x>0.

CODE:
a=[-2*pi:pi/12:2*pi];
b=[-1:.1:1];
c=[-20:1:20];
d=[-5:0.05:5];
e=[-20:20]
i=1;
for m=-20:20
if(m<0)
u(i)=0
else
u(i)=m
end
i=i+1

end
p=sin(a);
q=cos(a);
r=exp(b)
s=[zeros(1,20),ones(1,1),zeros(1,20)]
t=[zeros(1,100),1,ones(1,100)]
subplot(3,2,1)
plot(a,p)
xlabel('x')
ylabel('sin(x)')
title('Sine curve')

subplot(3,2,2)
plot(a,q)
xlabel('x')
ylabel('cos(x)')
title('Cosine curve')
subplot(3,2,3)
plot(b,r)
xlabel('x')
ylabel('e^x')
title('Exponential function')
subplot(3,2,4)
stem(c,s)
xlabel('time')
ylabel('del(t)')
title('Impulse function')
subplot(3,2,5)
plot(d,t)
xlabel('time')
ylabel('u(t)')
title('Unit step function')
subplot(3,2,6)
plot(e,u)
xlabel('time')
ylabel('r(t)')
title('Ramp function')

OUTPUT:

EXPERIMENT-2

AIM-Write a MATLAB code to show convolution of two signals and


verify this using multiplication in frequency domain.

THEORYIn 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.
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:

For complex-valued functions f, g defined on the set Z of integers, the discrete convolution of f
and g is given by

The convolution theorem for z transforms states that for any (real or)
complex causal signals
in the domain, i.e.,

and

or, using operator notation,

where

, and

, convolution in the time domain is multiplication

CODE:
clear all
close all
clc
w=-2*pi:0.1:2*pi;
s1=[2 2 3 7];
s2=[4 5 6];
t=conv2(s1,s2);
[h,w]=freqz(s1,1,w);
[p,w]=freqz(s2,1,w);
r=h.*p;
[m,n]=invfreqz(r,w,5,0);
subplot(2,2,1)
stem(s1);
xlabel('n-->')
ylabel('s1')
title('Signal 1')
subplot(2,2,2)
stem(s2);
xlabel('n-->')
ylabel('s2')
title('Signal 2')
subplot(2,2,3)
stem(t);
xlabel('n-->')
ylabel('conv')
title('Convolution')
subplot(2,2,4);
stem(m);
xlabel('n-->')
ylabel('I')
title('Inverse transform')

OUTPUT:

EXPERIMENT-3

AIM-Write a MATLAB code to plot the frequency response of an


LTI system.
THEORYFrequency response is the quantitative measure of the output spectrum of a
system or device in response to a stimulus, and is used to characterize the
dynamics of the system. It is a measure of magnitude and phase of the output as a
function of frequency, in comparison to the input
Frequency response can be effectively shown with the help of magnitude and phase
plots.
Consider these plots as examples:-

Function used:

[h,w] = freqz(b,a,n) returns the n-point frequency response vector, h, and the
corresponding angular frequency vector, w, for the digital filter with numerator and
denominator polynomial coefficients stored in b and a, respectively.
For eg the frequency response of the filter
H(z)= 1+ 2z-1 + 3z-2
can be calculated by taking
b=[1 2 3] and a=[1]

CODE:w=-pi:0.1:pi;
num=[1 2 3];
den=[4 5 6];
[h,w]=freqz(num,den,w);
mag=abs(h);
phase=angle(h);
subplot(3,1,1)
zplane(num,den);
subplot(3,1,2)
plot(w/pi,mag);
xlabel('Magnitude -->')
ylabel('Frequency -->')
title('Magnitude plot')
subplot(3,1,3)
plot(w/pi,phase);
xlabel('Phase -->')
ylabel('Frequency -->')
title('Phase plot')

OUTPUT:

EXPERIMENT-4

AIM- Write a MATLAB code to check the stability of a discrete time


system using Schr-Cohn Stability Test.
THEORYA polynomial is said to be stable if either:

all its roots lie in the open left half-plane, or

all its roots lie in the open unit disk.

The first condition provides stability for (or continuous-time) linear systems, and
the second case relates to stability of discrete-time linear systems. A polynomial
with the first property is called at times a Hurwitz polynomial and with the second
property a Schur polynomial.

A system is defined to be BIBO Stable if every bounded input to the system results
in a bounded output over the time interval . This must hold for all initial times to.
So long as we don't input infinity to our system, we won't get infinity output.
A signal is bounded if there is a finite value
magnitude never exceeds , that is

such that the signal

for discrete-time signals, or


for continuous-time signals.

For a discrete time LTI system, the condition for BIBO stability is that the impulse
response be absolutely summable, i.e.

Schr-Cohn Test:
Consider:

Define:

Define reverse polynomial:

The Schr-Cohn Stability test states that the polynomial Am(z) has all of its
roots inside the unit circle if and only if the reflection coefficients, Km , satisfy the
condition |Km|<1 for all m=1,2 ..... N . The reflection coefficients are found from
the following recursion:

where Km = am(m)

CODE:
n=input('Enter order of denominator polnomial
for i=1:n+1
a(i)=input('');
end
coeff=0;
coeff=a/a(1);
e=1;
flag=0;
for i=1:n
b=fliplr(coeff);
disp(coeff)
disp(b)
k=b(e);
if (k>1||k<-1)
flag=1;
break;
end;
temp=(coeff-k*b)/(1-(k^2));
for j=1:n+1;
coeff(j)=temp(j);
end
e=e+1;

end
if flag==1
disp('Unstable System ')
else if flag==0
disp('Stable System')
end
end

');

OUTPUT:

EXPERIMENT-5

AIM- Write a MATLAB code to show cross-correlation and autocorrelation of signals. Also show the auto-correlation and
convolution of unit step function

THEORY:
In signal processing, cross-correlation is a measure of similarity of two series as a
function of the lag of one relative to the other. This is also known as a sliding dot
product orsliding inner-product. It is commonly used for searching a long signal
for a shorter, known feature. It has applications in pattern recognition, single
particle analysis, electron tomography, averaging, cryptanalysis,
and neurophysiology.
for discrete functions, the cross-correlation is defined as:

Cross-correlations are useful for determining the time delay between two signals,
e.g. for determining time delays for the propagation of acoustic signals across a
microphone array

Autocorrelation, also known as serial correlation or cross-autocorrelation,[1] is


the cross-correlation of a signal with itself at different points in time (that is what

the cross stands for). Informally, it is the similarity between observations as a


function of the time lag between them. It is a mathematical tool for finding
repeating patterns, such as the presence of a periodic signal obscured by noise, or
identifying the missing fundamental frequency in a signal implied by
its harmonic frequencies. It is often used in signal processing for analyzing
functions or series of values, such as time domain signals.
The discrete autocorrelation

at lag for a discrete signal

is

CODE:
close all
clear all
clc
x=[1 4 1 3]
y=[2 5 6 7 1]
z=fliplr(x);
m=1:7;
n=1:8;
p=conv2(x,z);
q=conv2(z,y);
subplot(2,2,1)
stem(n,q)
xlabel('n -->')
ylabel('Rxy(n)-->')
title('Cross-Correlation')
subplot(2,2,2)
stem(m,p)
xlabel('n -->')
ylabel('Rxx(n)-->')
title('Auto-Correlation')
ut=[ones(1,11)]
r1=conv2(ut,ut);
g=0:20;
subplot(2,2,3)
stem(g,r1)
xlabel('n -->')
ylabel('Conv(n)-->')
title('Convolution[Unit step]')
h=-10:10;
ft=fliplr(ut)
r2=conv2(ut,ft);
subplot(2,2,4)
stem(h,r2)
xlabel('n -->')
ylabel('Ruu(n)-->')
title('Auto-Correlation[Unit Step]]')

OUTPUT:

You might also like