Question

1. Write a Matlab function to convolve two sequences objects: function y = conv(x, h) %...

1. Write a Matlab function to convolve two sequences objects:

function y = conv(x, h)
% CONV Convolve two finite-length Matlab sequence objects, x and h % returning sequence object, y.

When you convolve x[n] and h[n] , you may not use MATLAB's numerical conv routine.

2. write a second convolution function, conv_rt, in Matlab that basically implements a real-time convolu- tion strategy:

function y = conv_rt(x, h)
% Convolve two finite-length arrays, x and h
%          returning array, y

3. Write a function to deconvolve an output sequence:

function x = deconv(y, h)
% DECONV Convolve finite-length Matlab sequence object, y, % given impulse response sequence object, h
% returning sequence object, x.

%%lab2.m

test_lab2;

%% Convolution, Part I

% Convolution #1

x = sequence([1 2 6 -3 5], 1);

h = sequence([4 -1 5 3 2], -3);

test_lab2(x, h);

% Convolution #2

test_lab2(h, x);

% Convolution #3

h = sequence(1, 0);

test_lab2(x, h);

% Convolution #4

test_lab2(h, x);

% Convolution #5

x = sequence(cos(2 * pi * (1:50000) / 16), -5); % nice, big sequence

h = sequence(ones(1, 10), 10);

test_lab2(x, h);

% Convolution #6

test_lab2(h, x);

% Convolution #7

x = sequence(1, 2);

h = sequence(1, -1);

test_lab2(x, h);

% Convolution #8

test_lab2(h, x);

%% Real-time Convolution

% Real-time convolution #1

x = [1 4 2 6 5];

h = [4 -1 3 -5 2];

test_lab2a;

test_lab2a(x, h);

% Real-time convolution convolution #2

test_lab2a(h, x);

% Real-time convolution #3

x = cos(2 * pi * (1:50000) / 16); % nice, big sequence

h = ones(1, 10);

test_lab2a(x, h);

%% Deconvolution

% Deconvolution #1

h = sequence([1 3 2], 2);

y = sequence([1 6 15 20 15 7 2], -1);

test_lab2b;

test_lab2b(y, h);

% Deconvolution #1

y = sequence([-1 -2 0 0 0 0 1 2], 2);

test_lab2b(y, h);

%% Code

disp('---------------------------------------------------')

disp(' Code')

disp('---------------------------------------------------')

type sequence

type conv_rt

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
1. Write a Matlab function to convolve two sequences objects: function y = conv(x, h) %...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT