MATLAB HOMEWORK DUE IN THE MORNING PLEASE HELP QUICKLY! a.) This section of the
ID: 669946 • Letter: M
Question
MATLAB HOMEWORK DUE IN THE MORNING PLEASE HELP QUICKLY!
a.) This section of the code generates a discrete time signal x[n]. Generate a plot for x[n] and include it in your report. Include the mathematical equation for x[n].
The impulse response for this system is given by h[n]=u[n+8]-u[n-8]. Plot h[n] and include it in your report.
b.) Use the built-in conv() function in MATLAB to obtain y_a[n]=x(n)*h[n]. plot all three signals (x[n],h[n],y_a[n]) on the same figure using the subplot() function. ensure all axes and titles are labeled.
c.) Now, use the built-in conv() function in MATLAB to obtain y_b=h[n]*x[n]. Use subplot() to plot all three signals (x[n],h[n],y_b[n]) on the same figure. Add axis labels and titles to all three plots. In a new figure, use subplot() to plot y_a[n[ and y_b[n] and label the plots.
Are the two signals the same? Give a brief interpretation of your results.
SOMEBODY PLEASE WORK THIS OUT IN MATLAB AND GIVE ME THE CODE, I CANNOT FOR THE LIFE OF ME WORK IT OUT.
Explanation / Answer
CODE :
% Generation of a sinusoidal sequence
n = 0:40;
f = 0.1;
phase = 0;
A = 1.5;
arg = 2*pi*f*n - phase;
x = A*cos(arg);
clf; % Clear old graph
stem(n,x); % Plot the generated sequence axis([0 40 -2 2]);
grid;
title(’Sinusoidal Sequence’);
xlabel(’Time index n’);
ylabel(’Amplitude’);
axis;
% Simulation of an M-point Moving Average Filter
% Generate the input signal
n = 0:100;
s1 = cos(2*pi*0.05*n); % A low frequency sinusoid
s2 = cos(2*pi*0.47*n); % A high frequency sinusoid
x = s1+s2;
% Implementation of the moving average filter
M = input(’Desired length of the filter = ’);
num = ones(1,M);
y = filter(num,1,x)/M;
% Display the input and output signals
clf;
subplot(2,2,1);
plot(n,s1);
axis([0, 100, -2, 2]);
xlabel(’Time index n’); ylabel(’Amplitude’);
title(’Signal # 1’);
subplot(2,2,2);
plot(n,s2);
axis([0, 100, -2, 2]);
xlabel(’Time index n’); ylabel(’Amplitude’);
title(’Signal # 2’);
subplot(2,2,3);
plot(n,x);
axis([0, 100, -2, 2]);
xlabel(’Time index n’); ylabel(’Amplitude’);
title(’Input Signal’);
subplot(2,2,4);
plot(n,y);
axis([0, 100, -2, 2]);
xlabel(’Time index n’); ylabel(’Amplitude’);
title(’Output Signal’);
axis;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.