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

Tutorial 1 Q2 Q4 Matlab

Hdhdhe

Uploaded by

taliaalgul758
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)
10 views

Tutorial 1 Q2 Q4 Matlab

Hdhdhe

Uploaded by

taliaalgul758
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/ 3

Tutorial 1

Q2

% Define the original signal based on the given graph


n = -4:4; % Range of n
x = [-3, 0, 0.5, 0, 1, 1, 1, 0.5, 0]; % Signal values corresponding to the given graph
% 1. Plot for x(n-3) (right shift by 3 units)
n_shifted_1 = n + 3; % Shift to the right by 3
figure;
subplot(2,2,1);
stem(n_shifted_1, x, 'filled');
title('x(n-3)');
xlabel('n');
ylabel('x(n-3)');
grid on;
% 2. Plot for x(3-n) (time reversal and shift)
n_reversed_2 = 3 - n; % Reverse and shift
subplot(2,2,2);
stem(n_reversed_2, x, 'filled');
title('x(3-n)');
xlabel('n');
ylabel('x(3-n)');
grid on;
% 3. Plot for x(2n) (compression by a factor of 2)
n_compressed_3 = -2:2; % New range after compression
x_compressed_3 = [x(1), x(3), x(5), x(7), x(9)]; % Pick every second point
subplot(2,2,3);
stem(n_compressed_3, x_compressed_3, 'filled');
title('x(2n)');
xlabel('n');
ylabel('x(2n)');
grid on;
% 4. Plot for x(n)u(3-n) (multiplication by a step function u(3-n))
u_4 = double(n <= 3); % Define the unit step function u(3-n)
x_u_4 = x .* u_4; % Element-wise multiplication
subplot(2,2,4);
stem(n, x_u_4, 'filled');
title('x(n)u(3-n)');
xlabel('n');
ylabel('x(n)u(3-n)');
grid on;
Tutorial 1 Q 4
% Define the range for n
n = -2:2;
% Define the original signal x(n) = 2^(-n)
x = 2.^(-n);
% 1. Compute y1(n) = 2x(n) + delta(n)
delta_n = (n == 0); % Define the delta function (impulse at n=0)
y1 = 2 * x + delta_n;
% 2. Compute y2(n) = x(n) * u(2 - n)
u_2_n = (n <= 2); % Define the step function u(2-n)
y2 = x .* u_2_n; % Element-wise multiplication
% Plot x(n), y1(n), and y2(n)
figure;
% Plot original signal x(n)
subplot(3,1,1);
stem(n, x, 'filled');
title('x(n) = 2^{-n} for -2 \leq n \leq 2');
xlabel('n');
ylabel('x(n)');
grid on;
% Plot y1(n) = 2x(n) + delta(n)
subplot(3,1,2);
stem(n, y1, 'filled');
title('y_1(n) = 2x(n) + \delta(n)');
xlabel('n');
ylabel('y_1(n)');
grid on;
% Plot y2(n) = x(n) * u(2-n)
subplot(3,1,3);
stem(n, y2, 'filled');
title('y_2(n) = x(n)u(2-n)');
xlabel('n');
ylabel('y_2(n)');
grid on;

You might also like