%% Ameer Alkam

%% 1120217

%% main function
n = -4:1:2;
x = [1, -2, 4, 6, -5, 8, 10];

figure(1);
stem(n,x);

%% part A
[x1 , n1] = sigshift(x,n,2);
x1 = x1.*3;

[x2 , n2] = sigshift(x,n,-4);

x3 = -2.*x;

[y, ny] = sigadd(x1, n1, x2, n2);

[y, ny] = sigadd(y, ny, x3, n);

figure(2);
stem(ny, y);

%% partn B
[x1 , n1] = sigshift(x,n,5);
x1 = x1.*5;

[x2 , n2] = sigshift(x,n,4);
x2 = x2.*4;

x3 = 3.*x;

[y, ny] = sigadd(x1, n1, x2, n2);

[y, ny] = sigadd(y, ny, x3, n);

figure(3);
stem(ny, y);

%% part C
[x1 , n1] = sigshift(x,n,4);
[x2 , n2] = sigshift(x,n,-1);
x1 = x1.*x2;

[x2 , n4] = sigshift(x, -n,2);
x3 = x;

x2 = x2.*x3;

[y, ny] = sigadd(x1, n1, x2, n);

figure(4);
stem(ny, y);

%% part D
x1 = 2.*exp(n./2);
x1 = x1.*x;

[x2 , n2] = sigshift(x,n,2);
x2 = x2.*cos(0.1*pi.*n);

[y, ny] = sigadd(x1, n, x2, n2);

figure(5);
stem(ny, y);

%% part E
y = 0;
for k = 1:5
    [x1 , n1] = sigshift(x,n,-k);
    x1 = x1.*n;
    
    [y, ny] = sigadd(y, ny, x1, n1);
end

figure(6);
stem(ny, y);
