% 10-stage RC Filter

V = zeros(10,1);
dV = zeros(10,1);
V0 = 100;
dt = 0.01;
t = 0;

while(t < 100)

   dV(1)  = 10*V0   - 20.1*V(1) + 10*V(2);
   dV(2)  = 10*V(1) - 20.1*V(2) + 10*V(3);
   dV(3)  = 10*V(2) - 20.1*V(3) + 10*V(4);
   dV(4)  = 10*V(3) - 20.1*V(4) + 10*V(5);
   dV(5)  = 10*V(4) - 20.1*V(5) + 10*V(6);
   dV(6)  = 10*V(5) - 20.1*V(6) + 10*V(7);
   dV(7)  = 10*V(6) - 20.1*V(7) + 10*V(8);
   dV(8)  = 10*V(7) - 20.1*V(8) + 10*V(9);
   dV(9)  = 10*V(8) - 20.1*V(9) + 10*V(10);
   dV(10) = 10*V(9) - 10.1*V(10);

   V = V +  dV*dt;
   t = t + dt;

   hold off
   plot([0,10],[0,100],'w.');
   hold on
   plot([0:10], [V0;V], '.-');
   pause(0.01);
   end
