%
function smooted=rectFilt(x, width)
%smooting filter
smooted=zeros(1 , length(x));

if mod(width, 2)==0
    str=[num2str(width) ' is not odd, instead of ' num2str(width) ', ' num2str(width+1) ' is used.'];
    disp(str);
    width=width+1;
end

window=(width-1)/2;
for n=1:length(x)
    smooted(1,n)=mean(x(max(n-window, 1) : min(n+window, length(x))));
end

figure;
plot(x, 'bo', 'MarkerSize', 3, 'MarkerFaceColor', 'b');
hold on;
plot(smooted, '-r', 'LineWidth', 2);
title('Smoothing Illustration');
xlabel('Index');
ylabel('Data Value');
legend('Original Data', 'Smoothed');
end
%}
