Evaluate an integral in matlab -
i want compute following integral:
exp(-y^2/(2*a^2))* cosh(y)*log(cosh(y)) from y=0 y = inf
i need integral vector of values a? how can this?
as ikavanagh noticed, can not calculate integral using integral because outruns range of floating point values. thus, using symbolic toolbox possibility.
%define function: syms y f=exp(-y^2/(2*a^2))* cosh(y)*log(cosh(y)) now can calculate integral:
if=int(f,y,0,inf); at least in matlab version, explicit solution not found, warning raised. need 2 steps, substitute intended values, solve using vpa. in case recent matlab versions find explicit solution, use of vpa unnessecary.
solution=vpa(subs(if,a,[1,2,3,4]))
Comments
Post a Comment