clear all; clc;

b = [1 -1];
a = 1;
n = 0:1:100;

x = [n.*((n>=0)-(n>=10))] + [(20-n).*((n>=10)-(n>=20))]; %triangular pulse
y = filter(b,a,x);
figure;

subplot(211);
stem(n,x);
xlabel('n'); ylabel('x(n)');
grid on;
title('Triangular input');

subplot(212);
stem(n,y);
xlabel('n'); ylabel('y(n)');
grid on;
title('Output x(n)');