%7a
n=[-5:10]';
x=zeros(size(n));
ind=find(n>=0);
x(ind)=1;
subplot(2,1,1)
stem(n,x);
title('Lab1-Plot of #7a');
xlabel('n');
ylabel('Amplitude of x');
grid on

y=zeros(size(n));
indnz=ind(1);
for i=indnz:length(x)
    y(i)=0.25*y(i-1)+x(i);
end
subplot(2,1,2)
stem(n,y,'r');
title('Impulse response');
xlabel('n');
ylabel('Amplitude of y');
grid on

%7b
n=[-5:10]';
x=zeros(size(n));
ind=find(n==2);
x(ind)=1;
subplot(2,1,1)
stem(n,x);
title('Lab1-Plot of #7b');
xlabel('n');
ylabel('Amplitude of x');
grid on

y=zeros(size(n));
indnz=ind(1);
for i=indnz:length(x)
    y(i)=0.25*y(i-1)+x(i);
end
subplot(2,1,2)
stem(n,y,'r');
title('Unit Step Response');
xlabel('n');
ylabel('Amplitude of y');
grid on

%7c
n=[-5:10]';
x=zeros(size(n));
ind=find(n>=0 & n<=4);
x(ind)=1;
subplot(2,1,1)
stem(n,x,'r');
title('Lab1-Plot of #7c');
xlabel('n');
ylabel('Amplitude of x');
grid on

y=zeros(size(n));
indnz=ind(1);
for i=indnz:length(x)
    y(i)=0.25*y(i-1)+x(i);
end
subplot(2,1,2)
stem(n,y);
title('Resposne to Unit Step Difference');
xlabel('n');
ylabel('Amplitude of y');
grid on
