MATLAB: How to integral2

integral

how can i integral a function which was written in matlab but there is wrong , i dont no where it is :
syms tau
syms y
f= @(y,tau)y*exp(-0.5.*y.^2/ tau)
expecty=integral2(f, -2,4,0,Inf,'auto')

Best Answer

integral2 is defined for function handle, therefore you do not need symbolic variables:
f= @(y,tau)y.*exp(-0.5.*y.^2./ tau)
expecty=integral2(f, -2,4,0,Inf,'auto')