I think you forgot one .
with the last division:
g = @(y,a) (exp(((-1/a).*atanh(y)).^2).*cos((2/a).*atanh(y)).*(1/a).*(1./(1+y.^2)));
this works for me.
BTW: If you do it like this:
g = @(y,a) (exp(((-1./a)*atanh(y)).^2).*(cos((2./a)*atanh(y))).*((1./a)*(1./(1+y.^2))));
You can input both y
and a
as vectors:
g([-0.5 0 0.5],[1 2 3]')
ans =
0.49202 1.00000 0.49202
0.36789 0.50000 0.36789
0.25747 0.33333 0.25747
this reads:
g([a b c], [d e f]')
ans =
g(a,d) g(b,d) g(c,d)
g(a,e) g(b,e) g(c,e)
g(a,f) g(b,f) g(c,f)