Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

EGR324L: Linear Systems and Signals Lab Lab 4: Convolution Sum Objective To learn how to compute convolution sum in Matlab. Background Convolution Sum in Matlab Let x[n] be a discrete-time signal such...

1 answer below »
EGR324L: Linear Systems and Signals La
Lab 4: Convolution Sum
Objective
To learn how to compute convolution sum in Matlab.
Background
Convolution Sum in Matla
Let x[n] be a discrete-time signal such that x[n] = 0 for n < ox. Then x[n] can be denoted
y a pair , where vx = [ x[ox] x[ox+1 ] ... ] is an vector and x[ox] ≠ 0. In Fig. 1, x[n] =, where ox = -2 and vx = [ 1 -2]. And h[n] = , where oh = 3 and vh = [ XXXXXXXXXX].
Fig. l Representing general discrete time signals in Matla
It is easy to see that if x[ n] = , then x[n-n0] = .
A built-in function vy = conv( vx, vh) is provided by Matlab to compute the convolution sum of two vectors vx and vh. With our notation, this function actually computes <0, vy
= <0, vx> *<0, vh>.
In order to use function conv to calculate convolution sum for general discrete-time signals, a signal x[n] = must be shifted to the left for ox steps (if ox > 0), Let x1[n] =
0, vx> = x[n+ox] = x[n] * δ[n+ox]. For h[n] = , we may have h1[n] = <0, vh
= h[n+oh] = h[n] * δ[n+oh].
By invoking Matlab function vy = conv( vx, vh), we actually obtain
y 1 [n]    = <0, vy> = x1[n] * h1[n]
= (x[n] * δ[n+ox]) * (h[n] * δ[n+oh])
= (x[n] * h[n]) * δ[n+ox+oh]
Thus
3
x[n] * h[n] = y1[n] * δ[n-(ox+oh)]
= y1[n -(ox+oh)] = <0+ox+Oh, vy
= Example:
For signals x[n] and h[n] shown in Fig. 1, Matlab instructions for representing these two signals, and that for calculate the convolution sum of the two are given below.
Fig. 2 Computing convolution sum of general discrete-time signals in Matla
Preparation
You need to read the Matlab book for the following topics:
· more functions and commands for graphical plotting
· functions conv and deconv, rand and sound
· for statement and if statement in Matla
· relational operators >, <, >= <= ,==, ~=
· logic operators &, | and ~.
Problems
(1) Write a function [oy , vy ] = gconv(ox , vx, oh, vh) that computes generalized convolution sum = * , as defined in the background section of this handout.
(2) Using the function gconv defined in (2), and function trainplot defined in Lab 3, calculate and plot y[n] = x[n] * h[n], where x[n] and h[n] are shown as in Fig. 4.
Fig. 4 Compute convolution sum of two signals
(3) Using Matlab functions vy = conv( vx, vh) and [vh, vr] = deconv( vy, vx), solve Problem 9.17 in the textbook.
(4) A discrete-time system generating echoes of a sampled acoustic source is modeled as a causal and LTI system with unit impulse response
where 0 < a < 1 is called the attenuntion factor, N0 represents the time delay of the echo, and M is the smallest integer such that ak < d, a pre-specified "dead band ratio". For instance, if a = 0.5, d = 0.01,
Write a function y = gecho( x, a, N0, d), where column vector y is obtained by convolving input vector x with the system impulse response h, which depends on attenuation factor a, time delay N0 and dead band ratio d defined as above.
(5) Test function gecho with the following parameters.
Plot the vector generated by function gecho.
(6) Apply function gecho to a signal hi.mat (sampled at 8,192 Hz) using the following parameters.
attenuation factor: 0.7
echo delay time: 1 second
dead band ratio: 0.05
Play the processed signal using Matlab function sound(x).
(7) Repeat Step (6) for the following four sets of parameteters:
attenuation factor: 0.3    attenuation factor: 0.7
echo delay time: 1 second    echo delay time: 2 second
dead band ratio: 0.05    dead band ratio: 0.05
attenuation factor: 0.7    attenuation factor: 0.5
echo delay time: 1 second    echo delay time: 0.1 second
dead band ratio: 0.2    dead band ratio: 0.05
How do they compare with each other ? Do they sound like what you predicted?
You may wish to experiment this function with some other signals you sampled in the lab.
Report
As usual, you should turn in all the Matlab work. This includes all Matlab programs (.m files) as well as all graphical plots. Again, the audio signals should be plotted against time in seconds -- not in a
ay indices. Explain in detail how Matlab was used to solve the problems.
Describe the experiment you did in (6) and (7).
How do they compare with each other ? Do they sound like what you predicted?
(8)
(9) You may wish to experiment this function with some other signals you sampled in the lab.
(10)
(11) Report
(12)
(13) As usual, you should turn in all the Matlab work. This includes all Matlab programs (.m files) as well as all graphical plots. Again, the audio signals should be plotted against time in seconds -- not in a
ay indices. Explain in detail how Matlab was used to solve the problems.
(14)
(15) Describe the experiment you did in (7) and (8).
(16)
Report
As usual, you should turn in all the Matlab work. This includes all Matlab programs (.m files) as well as all graphical plots. Explain in detail how Matlab was used to solve the problems.
(
(
5
)
)
Answered Same Day Oct 05, 2021

Solution

Kshitij answered on Oct 10 2021
145 Votes
nw gray/ans2.m
ox=-2
vx=[1 -2];
oh=3;
vh=[-1 0 3 2];
[oy,vy]=gconv(ox,vx,oh,vh)
nw gray/ans5.m
x=rand(10,1)
a=0.5;
N0=100;
d=0.01
[y] = gecho(x, a, N0, d)
plot(y)
xlabel('Time')
ylabel('amplitude')
nw gray/ans6.m
x=rand(100,1)
sound(x)
a=0.7;
N0=100;
d=0.05
[y] = gecho(x, a, N0, d)
plot(y)
xlabel('Time')
ylabel('amplitude')
nw gray/ans7.m
x=rand(100,1)
a=0.7;
N0=10;
d=0.05
[y] = gecho(x, a, N0, d)
plot(y)
xlabel('Time')
ylabel('amplitude')
nw gray/answer3.m
%a) if N=4
clc;
clear all;
close all;
n=0:5;%%creating time vecto
N=4;%%taking N=4
x=(n>=0)-(n>=(N+1));%%generating x[n] sequence
h=(n>=0)-(n>=4);%%generating h[n] sequence
y=conv(x,h);%%convolution of x[n] and h[n]
disp(y);%%displaying y[n]
stem(y);%%plootting y[n]
xlabel('n--->');
ylabel('y[n]--->');
title('convoltion of x[n) and h[n]')
%%b)calculting the value of N<=5 for which y[3]=3 and y[6]=0
for N=0:5%%taking for loop for N from 0 to 5
x=(n>=0)-(n>=(N+1));%%calculting x[n] for each value of N
y1=conv(x,h);%% calculating new convolution sequence
if (y1(3+1)==3 & y1(6+1)==0)%%comparing x[3]=3 and y[6]=0
fprintf('the N values for y[3]=3 and y[6]=0 is %d \n ',N)
end
end
nw gray/gconv.m
function [oy,vy]=gconv(ox,vx,oh,vh)
nx=ox:1:length(vx)+ox; % Defining Axis for Vx vecto
nh=oh:1:length(vh)+oh; % Defining Axis for Vh vecto
vy=conv(vx,vh); %...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here