You need to understand functions and function handles, and the difference between symbolic tools and numerical tools.
integral is a numerical tool. It performs numerical integration. NO parameters in such a function can be symbolic. Anyway, numerical integration with infinite limits can be a risky thing, because subdividing infinite intervals is always a problem. How, for example, do you find the point midway in the interval [-inf,inf]?
Next, when you define a function like this:
MATLAB does not recognize that psi is actually a function of y. If psi is a function of y, then write it as
However, as you have written it, psi is a symbolic variable, not truly a function of any input. So this is not a function, even though you may choose to think of it as such:
psi = hermiteH(0,y).*exp(((-y).^2)./2);
So, you have quite a few problems in the code you wrote. The main problem is if you need to work with symbolic parameters, then you need to use int, not integral.
Best Answer