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

matlab report 1

Uploaded by

kavi20053878
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

matlab report 1

Uploaded by

kavi20053878
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Lab Report-1

Question 1:
Generating a step signal: x(n)= {1,1,1 …...}.

Code:
n = 0:10;
x = ones(size(n));
stem(n, x);
xlabel('n');
ylabel('x(n)');
title('Step Signal x(n)');
grid on;

Inference:
Step signal remains constant at 1 after time n=0.This signal model starts at
time n=0 and continues indefinitely (or for a defined period).

Output:

Question 2:
n
Integrator: y(n)= ∑ x . Plot the poles and zeroes of the integrator.
k

k=−∞

Code:
numerator = 1;
denominator = [1 -1];
figure;
zplane(numerator, denominator);
title('Pole-Zero Plot of the Integrator');
grid on;

Inference:
The zero is at infinity. The pole is at z=1.

Output:

Question 3:
Differentiator: y(n)=x(n)-x(n-1). Plot the poles and zeroes of the differentiator.

Code:
numerator = [1 -1];
denominator = 1;
figure;
zplane(numerator, denominator);
title('Pole-Zero Plot of the Differentiator');
grid on;

Inference:
The zero is at z=1, The poles are at infinity.
Output:

Question 4:
Generating a sinusoid: Consider a sinusoid of frequency 200 hz. It is sampled at
fs= i) 500 hz ii) 1000 hz iii) 2000 hz. Plot them. Plot x(n) for the above
cases for n= [1:1000].

Code:
% Define parameters
A = 1;
f0 = 200;
n = 1:1000;
% Sampling frequencies
fs1 = 500;
fs2 = 1000;
fs3 = 2000;
% Sampling intervals
t1 = n / fs1;
t2 = n / fs2;
t3 = n / fs3;

% Generate the sampled signals


x1 = A * cos(2*pi*f0*t1);
x2 = A * cos(2*pi*f0*t2);
x3 = A * cos(2*pi*f0*t3);
% Plot the signals
figure;

subplot(3,1,1);
plot(t1, x1);
title('Sampled Signal at 500 Hz');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;

subplot(3,1,2);
plot(t2, x2);
title('Sampled Signal at 1000 Hz');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;

subplot(3,1,3);
plot(t3, x3);
title('Sampled Signal at 2000 Hz');
xlabel('Time (s)');
ylabel('Amplitude');
grid on;

subplot(3,1,4);
plot(t4,x4);
title('Sampled signal at 200 Hz');
xlabel('Time(s)');
ylabel('Amplitude');
grid on;
% Display the figure
sgtitle('Sampled Sinusoids at Different Sampling Frequencies');

Inference:
At fs = 500 Hz: The sampling rate is low compared to the signal frequency,
which may cause aliasing. You might observe distortion or poor reconstruction of
the sinusoid.
At fs = 1000 Hz: This is the Nyquist rate for a 200 Hz signal, and the sinusoid
should be represented reasonably well.
At fs = 2000 Hz: The signal is well-sampled and reconstructed with high fidelity,
showing a clear sinusoidal waveform.

Question 5:
Consider a system h(n) with impulse response h(n)= [1 1 1 1 1 1 1 1 1 1]. Plot
the poles and zeroes of the system. Convolve the sinusoid x(n)= 10cos(πn/5).

Code:
numerator = [1 zeros(1,9) -1];
denominator = [1 -1 zeros(1,8)];
figure;
zplane(numerator, denominator);
title('Pole-Zero Plot');
grid on;
h = ones(1, 10);
n = 0:99;
x = 10 * cos(pi * n / 5);
y = conv(x, h);
figure;

subplot(3,1,1);
plot(n, x);
title('x(n)');
xlabel('n');
ylabel('x(n)');
grid on;
subplot(3,1,2);
stem(0:9, h, 'filled');
title('h(n)');
xlabel('n');
ylabel('h(n)');
grid on;

subplot(3,1,3);
plot(0:length(y)-1, y);
title(' y(n) = x(n) * h(n)');
xlabel('n');
ylabel('y(n)');
grid on;

Inference:
The system's impulse response h(n) consists of 10 consecutive ones. This
represents a Finite Impulse Response (FIR) filter. All poles are at the origin.
Convolution of the input signal with the system's impulse response modifies the
original sinusoidal signal, likely reducing any sharp variations or high-frequency
noise.

Question 6:
Consider a difference equation
y(n)=ay(n-1) +x(n) , where a=0.9. Obtain the poles and zeroes of the system
[Take a=0.9, x(n)=ones (1,1000)]. Convolve x(n) and h(n), where the system is
given by y(n)=ay(n-1) +x(n). Plot the x(n) and output y(n) for n=[1, …… 1000].
Explain the result.

Code:
numerator = [1 0];
denominator = [1 -0.9];

figure;
zplane(numerator, denominator);
title('Pole-Zero ');
grid on;
a = 0.9;
n = 1:100;

x = ones(1, 100);

h = a.^(0:99);

c = conv(x, h);
c = c(1:100);

figure;
subplot(2,1,1);
plot(n, x);
title('x(n)');
xlabel('n');
ylabel('x(n)');
grid on;

subplot(2,1,2);
plot(n, c);
title('x(n) * h(n)');
xlabel('n');
ylabel('y(n)');
grid on;

a = 0.9;
n = 1:100;
x = ones(1, 100);
y = zeros(1, 100);

for i = 1:100
if i == 1
y(i) = x(i);
else
y(i) = a * y(i-1) + x(i);
end
end

figure;

subplot(2,1,1);
plot(n, x);
title('x(n)');
xlabel('n');
ylabel('x(n)');
grid on;

subplot(2,1,2);
plot(n, y);
title('y(n)');
xlabel('n');
ylabel('y(n)');
grid on;

Inference:
The system acts as a smoother or low-pass filter, with the past influencing the
future output. The output signal stabilizes after an initial transient response,
which is characteristic of many systems with feedback.
Question 7:
Perform linear convolution without using the built-in MATLAB ‘conv’ function.

Code:
x = ones(1, 10);
h = 0.9.^(0:9);
Lx = length(x);
Lh = length(h);
L_y = Lx + Lh - 1;
y = zeros(1, L_y);

for n = 1:Lx+Lh-1
for k = 1:Lx
if (n - k + 1 > 0 && n-k+1 < Lx)
y(n) = y(n) + x(n - k + 1) * h(k);
end
end
end
figure;
subplot(3,1,1);
plot(1:Lx, x);
title('x(n)');
xlabel('n');
ylabel('x(n)');
grid on;

subplot(3,1,2);
stem(0:length(h)-1, h, 'filled');
title('h(n)');
xlabel('n');
ylabel('h(n)');
grid on;
subplot(3,1,3);
plot(1:L_y, y);
title('y(n) - Manual Convolution');
xlabel('n');
ylabel('y(n)');
grid on;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy