0% found this document useful (0 votes)
5 views1 page

Ex 7.m

Uploaded by

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

Ex 7.m

Uploaded by

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

% Clear workspace and command window

clear; clc;

% Define the system coefficients


b = [1, -0.5, 0.25];
a = 1;

% Generate a sample input signal


n = 0:10; % Time index
x = sin(0.1 * pi * n); % Input signal (sine wave)

% Apply the system to the input signal


y = filter(b, a, x);

% Shift the input signal by one sample


x_shifted = [0, x(1:end-1)];

% Apply the system to the shifted input signal


y_shifted = filter(b, a, x_shifted);

% Verify shifting characteristics


is_shifting = isequal(y(2:end), y_shifted(2:end));

% Plot the original and shifted input signals


subplot(2, 1, 1);
stem(n, x, 'b', 'Marker', 'o', 'LineWidth', 1.5);
hold on;
stem(n, x_shifted, 'r', 'Marker', 'x', 'LineWidth', 1.5);
title('Original and Shifted Input Signals');
xlabel('n');
ylabel('Amplitude');
legend('Original Input (x[n])', 'Shifted Input (x[n-1])');
hold off;

% Plot the output signals


subplot(2, 1, 2);
stem(n, y, 'b', 'Marker', 'o', 'LineWidth', 1.5);
hold on;
stem(n, y_shifted, 'r', 'Marker', 'x', 'LineWidth', 1.5);
title('Output Signals');
xlabel('n');
ylabel('Amplitude');
legend('Output for Original Input (y[n])', 'Output for Shifted Input (y[n-1])');
hold off;

% Display a message about shifting characteristics


if is_shifting
msg = 'The system has shifting characteristics.';
else
msg = 'The system does not have shifting characteristics.';
end

% Add annotation to the figure


annotation('textbox', [0.15, 0.1, 0.7, 0.1], 'String', msg, 'FitBoxToText', 'on',
'BackgroundColor', 'w');

% Adjust layout
sgtitle('Shifting Characteristics Verification');

You might also like