You are on page 1of 3

Practical 01

Aim:
1) To plot a continuous and discrete function and find energy and power of a
function
2) Find convolution of discrete functions
Theory: Discuss about signal energy and power and discreet convolution.
Program 01:
1. Generate signal exp(-t).*cos(2*pi*t) and combined operation
2. Generate unit step u(t) and flip operation
3. Generate signal exp(-t)*(u(t) - u(t-1)) and find signal energy
% Generate signal exp(-t).*cos(2*pi*t) and combined operation.
f = @(t)exp(-t).*cos(2*pi*t).*(t>=0)
t = -2:0.01:2;
subplot(2,2,1)
plot(t,f(t))
subplot(2,2,2)
plot(t,f(2*t+1))
% Generate unit step u(t) and flip operation
u = @(t)t>=0
subplot(2,2,3)
plot(t,u(t))
axis ([-1 2 -.1 1.1]);
subplot(2,2,4)
plot(t,u(-t))
axis ([-1 2 -.1 1.1]);
% Generate signal exp(-t)*(u(t) - u(t-1))
g = @(t)exp(-t).*(t>=0 & t<1)
% Signal Energy
E = sum(g(t).*g(t)*0.01)
figure(2)
plot(t,g(t))

Exercise:
1. Generate a ramp function in the time range [0,1] and find its energy.
2. Generate a function

t 0<t< 1
x ( t )=1 1< t<2
2 2< t<3

3. Perform following operations on the function x(t)


x(-t)
x(2t)
x(2t+1)
Program 2: Discrete function power and energy
clc;
clear all;
% sampling rate
fs = 100;
n = 0:1:100;
%Generate and plot the signal
x1 = cos(10*pi*2.*n/fs);
stem(n,x1)
% Find the period
x2 =x1;
%Generate Dummy Signal
[C,I1] =max(x2);
for n = 1 :1: length(x1);
if n==I1
x2(n) =0;
end
end
[c, I2] = max(x2);
%Find the Period
N = I2 - I1
%Find the energy
x = x1(1:N);
P = sum(abs(x).*abs(x))/N
Program 3: Convolution of
clc
clear all;
h = @(n) 0.5.^n .*(n>=0);
n = 0:60
subplot(1,2,1)
stem(n,h(n))
isnumeric(h(n))
x = @(n)0.25.^n.*(n>=0)
subplot(1,2,2)
stem(n,x(n))
x1 = x(n)

1 n ( ) 1 n
u n
u(n)
2
4

()

()

h1 = h(n)
x1 = double(x1)
h1 = double(h1)
size(h1)
size(x1)
y = conv2(h1, x1);
figure(2)
stem(y)
Exercise
1. Find u[n]*u[n]
2. Find convolution of sin(pi*n/3) and n*u[n]

You might also like