Code
clc
clear all
close all
x = [1 -2 4 6 -5 8 10]; %input('enter the sequence')
n1 = -4:2; %('enter the time duration')
subplot(411);
stem(n1, x);
title('input signal');
xlabel('Index (n)');
ylabel('Amplitude');
[y1,n] = shifting(x,n1,4)
subplot(412);
stem(n, y1)
title('shifted by 4');
xlabel('Index (n)');
ylabel('Amplitude');
[y2,n2] = shifting(x,n1,-2)
subplot(413);
stem(n2, y2)
title('Shifted by -2');
xlabel('Index (n)');
ylabel('Amplitude');
% y = 3*y2+y1-2*x;
[sum1,n5] = signaladd(y1,n,3*y2,n2);
[y,n6] = signaladd(sum1,n5,-2*x,n1);
subplot(414);
stem(n6, y)
title('output signal');
xlabel('Index (n)');
ylabel('Amplitude');
Shifting
function [y,n] = shifting(x,n1,k)
n = n1+k;
y = x;
end