Integral/Calc issues: normalizing wave function
显示 更早的评论
I'm trying to normalize a harmonic oscillator wave function. I'm getting multiple error codes, mostly involving the integral (see below code).
syms hbar a h m k y x N w v
hbar = h/(2*pi);
a= (hbar^0.5)/(m^0.25*k^0.25);
w = (k^0.5)/(m^0.5);
y=x/a;
%normalization for V=0
psi = hermiteH(0,y).*exp(((-y).^2)./2);
f = @(y) psi*psi;
F = integral(f,-Inf,Inf);
N=sqrt(1./F)
Error using integralCalc/finalInputChecks (line 511) Input function must return 'double' or 'single' values. Found 'sym'.
Error in integralCalc/iterateScalarValued (line 315) finalInputChecks(x,fx);
Error in integralCalc/vadapt (line 132) [q,errbnd] = iterateScalarValued(u,tinterval,pathlen);
Error in integralCalc (line 103) [q,errbnd] = vadapt(@minusInfToInfInvTransform,interval);
Error in integral (line 88) Q = integralCalc(fun,a,b,opstruct);
Error in Untitled (line 12) F = integral(f,-Inf,Inf);
I have a feeling its simply just the integral. But I don't understand the error code! Thank you!
采纳的回答
更多回答(1 个)
Steven Lord
2016-4-23
0 个投票
The integral function performs numeric integration. The int function performs symbolic integration. Alternately, if you want to use integral you will need to convert your symbolic expression into something that can be evaluated numerically
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!