%%%% File does an example convolution using a spatial box filter in 1D %%%%
clear all;close all;clc;

f=[16] %number of points to filter over (f=L/delta)

load iso_vel128.mat

Ux = squeeze(U(:,64,64));
clear U;clear V;clear W;
xdim = length(Ux);
xf   = zeros(xdim);
xbig = [Ux(xdim-f/2:xdim);Ux;Ux(1:f/2)];          %periodic in x

xf=Ux;
for i=1:xdim
    xbox=zeros(xdim,1);
    xf(i)=mean(xbig(i:i+f));
    if((i-f) < 0)
        xbox(1:i)=1;
    elseif(i > xdim-f/2)
        xbox(i:xdim)=1;
    else
        xbox(i-f/2:i+f/2)=1;
    end
    figure(1);
    subplot(211);plot(xf,'LineWidth',2);axis([1 128 -1.5 1.5])
    subplot(212);plot(xbox,'LineWidth',2);axis([1 128 0 2])
    pause(0.1)
end