ti0_TN=0.16438;
tim_TN=fzero(@wf_TN_1_1,[0.0 ti0_TN]);
function [gy]=wf_TN_1_1(x)
ti0_TN=0.16438;
D_TN=6.6E-6;
tim_TN=x;
gy1=ab_TN_1(tim_TN,ti0_TN,@TN_f1);
gy=(gy1-(D_TN/2))/(D_TN/2);
end
function =ab_TN_1(down,up,f) %integral subroutine, where double(*f)(double) is the integral function, down and up is the limit of integal
xi=[0.0,-0.90618,-0.538469,0.0,0.538469,0.90618];
ai=[0.0,0.236927,0.478629,0.568889,0.478629,0.236927];
tol=1e-3;
mm=1;
c1=abs(down)+abs(up);
r1=0;
while(1)
s=0;
h1=(up-down)/mm;
for i=1:mm
aa=down+h1*(i-1);
bb=aa+h1;
for j=1:6
x_TN=0.5*((bb-aa)*xi(j)+aa+bb);
s=s+ai(j)*f(x_TN);