Integral/Calc issues: normalizing wave function
Afficher commentaires plus anciens
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!
Réponse acceptée
Plus de réponses (1)
Steven Lord
le 23 Avr 2016
0 votes
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
Catégories
En savoir plus sur Programming dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!