Question: program below did not work in MATLAB. Please help function [y, h] = mySystem(x, h1, h2, h3, h4) % compute total impulse response by convolving

program below did not work in MATLAB. Please help function [y, h]program below did not work in MATLAB. Please help

function [y, h] = mySystem(x, h1, h2, h3, h4)

% compute total impulse response by convolving h1 and h2, and subtracting the convolution of h1, h3, and h4

h = conv(h1, h2) - conv(h1, conv(h3, h4));

% compute output response by convolving input signal x with total impulse response h

y = conv(x, h);

% plot total impulse response h and output response y on the same figure using subplots

figure;

subplot(2,1,1);

stem(0:length(h)-1, h); % plot h using stem plot, with n=0 at leftmost index

title('Total Impulse Response');

xlabel('n');

ylabel('h[n]');

subplot(2,1,2);

stem(0:length(y)-1, y); % plot y using stem plot, with n=0 at leftmost index

title('Output Response');

xlabel('n');

ylabel('y[n]');

end

Create a Function Representing a Total Impulse Response Create a function named 'mySystem', which has the following input and output arguments. Input x - the input signal (vector) h1,h2,h3, and h4 - the impulse responses (vectors) Output y - the output response (vector) h - total impulse response (vector) The function computes for the total impulse response h and convolves it, using the conv function, with the input signal x to get the output response y. The first elements of the vectors are at n=0. The individual impulse responses h1,h2,h3, and h4 are arranged as shown below. The function must also plot the discrete-time h and y in a single figure, with y on top of h

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!