0% found this document useful (0 votes)
8 views2 pages

Sns 3 Exp

Uploaded by

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

Sns 3 Exp

Uploaded by

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

% Define the first sequence x[n]

X = [1, 2, 3, 4]; % Example sequence

% Define the second sequence h[n]

H = [2, 1, 0, -1]; % Example sequence

% Perform linear convolution using the conv function

Y = conv(x, h);

% Define the range of n for plotting

Nx = 0:length(x)-1; % Range of n for x[n]

Nh = 0:length(h)-1; % Range of n for h[n]

Ny = 0:length(y)-1; % Range of n for y[n]

% Plotting the sequences and their convolution

Figure;

% Subplot 1: Plot x[n]

Subplot(3, 1, 1);

Stem(nx, x, ‘filled’); % Stem plot for discrete sequences

Title(‘Sequence x[n]’);

Xlabel(‘n’);

Ylabel(‘Amplitude’);

Grid on;

% Subplot 2: Plot h[n]

Subplot(3, 1, 2);

Stem(nh, h, ‘filled’);

Title(‘Sequence h[n]’);

Xlabel(‘n’);

Ylabel(‘Amplitude’);

Grid on;

% Subplot 3: Plot y[n] (Linear Convolution)

Subplot(3, 1, 3);

Stem(ny, y, ‘filled’);

Title(‘Linear Convolution y[n] = x[n] * h[n]’);

Xlabel(‘n’);

Ylabel(‘Amplitude’);

Grid on;

% Overall title for the figure

Sgtitle(‘Linear Convolution of Two Sequences’);

You might also like