% Generate signal with peaks and noise
x = 0:0.1:10;
y = sin(x) + 0.5*randn(size(x));

% Create figure with two horizontal subplots
figure;
subplot(2,1,1);
plot(x,y);
title('Original Signal');

% Apply sliding average smooth of different widths
width1 = 5;
smooth1 = filter(ones(1,width1)/width1,1,y);

width2 = 10;
smooth2 = filter(ones(1,width2)/width2,1,y);

width3 = 15;
smooth3 = filter(ones(1,width3)/width3,1,y);

% Plot smooth signals in bottom subplot
subplot(2,1,2);
hold on;
plot(x,smooth1,'r-','LineWidth',2);
plot(x,smooth2,'g--','LineWidth',2);
plot(x,smooth3,'b:','LineWidth',2);
legend(sprintf('Width = %d',width1), sprintf('Width = %d',width2), sprintf('Width = %d',width3));
title('Smoothed Signal');
hold off;