function acausal_demo
ode23('acausal')
hold on
axis([-10,10, -.2,1.15])
plot([-10,0],[0,0],'-or',[0,0],[0,1],'--k')
plot([0,10],[1,1],'-or',...
'MarkerFaceColor','r')
xlabel('Time')
title('Acausal Filter')
hold off

function [out1,out2,out3]=acausal(t,y,flag)
% To run the demo, use the command 
%          ode23('acausal')
% This gives the effect of an ideal filter acting on a function that
% is 1 for 0 <= t <=1 and 0 for t<0 or t>1. This file is a modified
% version of MATLAB's odefile. 

if nargin < 3 | isempty(flag),  
  y=ones(size(t)); 
  z=y;
  nn=find(t~=0); 
  mm=find(t~=1);
  y(nn)=sin(pi*t(nn))./(pi*t(nn)); %sinc(t)
  z(mm)=sin(pi*(t(mm)-1))./(pi*(t(mm)-1)); %sinc(t-1)
  out1= y-z; %ydot=sinc(t)-sinc(t-1)

else
   switch flag
      case 'init' % Return default [tspan,y0,options].
         out1=[-10,10]; % tspan
         out2=0;  % Initial conditions given as a column vector.
         out3=[]; % Default options are used.
      otherwise
         error(['Unknown flag ''' flag '''.']);
   end
end