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!