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!