MATLAB: Double integration plot error. messed up with vector and syms

numerical integrationplot

Could you help me with this? tried to plot, but error comes out. messed up with vector and syms?
zR=0.0201;
z0=1.0264;
tau=0.5;
nu0=2.606;
Lw=1.0810;
lambda=2.68*10^-6;
c=3*10^8;
k0=2*pi/lambda;
omega=2*pi*c/lambda;
xi =@(t,xi0) xi0+nu0.*tau-exp(t)/nu0.^2*(cos(xi0+nu0*tau)-cos(xi0)+nu0.*tau.*sin(xi0));
zeta= @(t,xi0) xi/(zR*k0);
f = @(xi0,x0,t) exp(x0.^2/(1+zeta(t,xi0).^2)-i*(zeta(t,xi0).*x0.^2/(1+zeta(t,xi0).^2)-atan((zeta(t,xi0)))+7*(xi(t,xi0))));
xT = @(T) T;
T=linspace(0,1);
t= xT(T);
F= zeros(size(T));
for K = 1 : length(T)
F(K) = abs(integral2(@(xi0,x0) f(t(K), xi0, x0), -3*k0*zR, 3*k0*zR, -1, 1));
end
plot(t, F)

Best Answer

Your
zeta= @(t,xi0) xi/(zR*k0)
needs to be @(t,xi0) xi(t,xi0)/(zR*k0)
Your
f = @(xi0,x0,t) exp(x0.^2/(1+zeta(t,xi0).^2)-i*(zeta(t,xi0).*x0.^2/(1+zeta(t,xi0).^2)-atan((zeta(t,xi0)))+7*(xi(t,xi0))));
needs at least some of the / changed to ./ because it will be evaluated on vectors.
Your f is defined with t as the third argument, but in your F(K) definition you call
f(t(K), xi0, x0)
with t as the first argument.