0% found this document useful (0 votes)
106 views

Lab 12 DSP

This document contains 6 questions regarding linear time-invariant systems and signal processing. Question 1 asks which component of a summed input signal x[n] is suppressed by a discrete-time system. Question 2 implements a moving average filter on summed sinusoidal inputs and plots the results. Question 3 varies the filter length and input frequencies in the same system. Question 4 similarly processes summed sinusoidal inputs but allows the user to define the frequencies. Question 5 compares the output of a linear system with summed weighted inputs to the summed weighted outputs of the individual inputs. Question 6 modifies the previous program to use a different non-linear system.

Uploaded by

Waleed Tahir
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
106 views

Lab 12 DSP

This document contains 6 questions regarding linear time-invariant systems and signal processing. Question 1 asks which component of a summed input signal x[n] is suppressed by a discrete-time system. Question 2 implements a moving average filter on summed sinusoidal inputs and plots the results. Question 3 varies the filter length and input frequencies in the same system. Question 4 similarly processes summed sinusoidal inputs but allows the user to define the frequencies. Question 5 compares the output of a linear system with summed weighted inputs to the summed weighted outputs of the individual inputs. Question 6 modifies the previous program to use a different non-linear system.

Uploaded by

Waleed Tahir
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Lab 1

Question 1:

Run the Program P1_8 for M = 2 to generate the output signal with x[n] = s1[n] + s2[n] as the input.
Which component of the input x[n] is suppressed by the discrete-time system simulated by this program?







Question 2:

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;
M = input('Desired length of the filter = ');
% As you can see that "num" actually contains the impulse response (times the
constant % M). What we are actually doing in Q2.2 is multiplying the
% impulse response of the low pass filter by the sequency (-1)^n.
num = (-1).^[0:M-1]; % y[n]= 0.5()
y = filter(num,1,x)/M;
% Display the input and output signals
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;


Questions 3: Run Program P1_8 for other values of filter length M, and various values of the frequencies
of the sinusoidal signals s1[n] and s2[n]. Comment on your results.






QUESTION 4:

Use sinusoidal signals with different frequencies as the input signals and compute the output signal for
each input. How do the output signals depend on the frequencies of the input signal?

n = 0:100;
f1=input('enter frequency of 1st signal low frequency = ');
f2=input('enter frequency of 2nd signal high frequency = ');
s1 = cos(2*pi*f1*n); % A low frequency sinusoid
s2 = cos(2*pi*f2*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
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');






Question 5:
Run Program P1_3 and compare y[n] obtained with weighted input with yt[n] obtained by combining the
two outputs y1[n] and y2[n] with the same weights. Are these two sequences equal? Is this system linear?
clc
n = 0:40;
a = 4;
b = 4;
x1 = cos(2*pi*0.1*n);
x2 = cos(2*pi*0.4*n);
x = a*x1 + b*x2;
num = [2.2403 2.4908 2.2403];
den = [1 -0.4 0.75];
ic = [0 0];
% Set zero initial conditions
y1 = filter(num,den,x1,ic); % Compute the output y1[n]
y2 = filter(num,den,x2,ic); % Compute the output y2[n]
y = filter(num,den,x,ic); % Compute the output y[n]
yt = a*y1 + b*y2;
d=y-yt; % Compute the difference output d[n]
% Plot the outputs and the difference signal
subplot(3,1,1);
stem(n,y);
ylabel('Amplitude');
title('Output Due to Weighted Input: a \cdot x_{1}[n] + b \cdot x_{2}[n]');
subplot(3,1,2);
stem(n,yt);
ylabel('Amplitude');
title('Weighted Output: a \cdot y_{1}[n] + b \cdot y_{2}[n]');
subplot(3,1,3);
stem(n,d);
ylabel('Amplitude');
xlabel('Time index n');
title('Difference Signal')


GRAPH:


Question 6:

Consider another system described by: y[n] = x[n] x[n 1].
Modify Program P1_3 to compute the output sequences y1[n], y2[n], and y[n] of the above system.
Compare y[n] with yt[n]. Are these two sequences equal? Is this system linear?

You might also like