clear 
hold off
format compact

load U:\LANL\SPICE\PBAM34_GAIN1\out2.txt
t=out2(:,1);
x=out2(:,2);

up=5;
j=1;
for i=1:120
 y(up*(i-1)+1)=0;
 tu(up*(i-1)+1)=1e-9*(up*(i-1)+1);
 y(up*(i-1)+2)=0;
 tu(up*(i-1)+2)=1e-9*(up*(i-1)+2);
 y(up*(i-1)+3)=0;
 tu(up*(i-1)+3)=1e-9*(up*(i-1)+3);
 y(up*(i-1)+4)=0;
 tu(up*(i-1)+4)=1e-9*(up*(i-1)+4);
 while t(j) < i*5e-9
  j=j+1;
 end
 tu(up*(i-1)+up)=5e-9*(up*(i-1)+up)/up;
 y(up*(i-1)+up)=x(j);
end

%up=1;
%j=1;
%for i=1:120
% while t(j) < i*5e-9
%  j=j+1;
% end
% tu(up*(i-1)+1)=5e-9*(up*(i-1));
% y(up*(i-1)+1)=x(j);
%end

figure(1),plot(tu,y,'+')
ym=y-mean(y);
f=fft(ym);
%figure(2),plot(abs(f))

[z,p,k]=butter(10,.17);
[num,den]=zp2tf(z,p,k);
yf=5*dlsim(num,den,y);
hold
figure(1),plot(tu,yf,'g')

