How do I use parameters in the upper and lower limits of an intergral?

1 次查看(过去 30 天)
Hi, I have the following code
if true
% code
end
syms h g x C n L p e E C m
h = 1.0545718E-34
g = 5.344285879E-28
m = 9.10938356E-31
E = h^2/8*m*L^2
y = - (exp(-(x*(g*1i + (- 2*g^2 + E)^(1/2)))/h)*(g*1i - (- 2*g^2 + E)^(1/2)))/(2*(E - 2*g^2)^(1/2)) + (exp(-(x*(g*1i - (- 2*g^2 + E)^(1/2)))/h)*(g*1i + (- 2*g^2 + E)^(1/2)))/(2*(E - 2*g^2)^(1/2))
z = - (exp(-(x*(g*(-i) + (- 2*g^2 + E)^(1/2)))/h)*(g*(-i) - (- 2*g^2 + E)^(1/2)))/(2*(E - 2*g^2)^(1/2)) + (exp(-(x*(g*(-i) - (- 2*g^2 + E)^(1/2)))/h)*(g*(-i) + (- 2*g^2 + E)^(1/2)))/(2*(E - 2*g^2)^(1/2))
v = i*h*diff(z, x)
S = y*z
W = [int(S, 0, L)] % Operator check hermiticity
vpa(W) % vpa= Variable precision arithmetic, simplifies the large fractions to nunmbers
however the upper limit set to L is not accepted by MATLAB. Is there any chance of telling MATLAB to treat this as a constant?
Thanks

采纳的回答

Birdman
Birdman 2018-1-4
The same code works me without any error, including vpa(W). To decide number of digits, use the following:
vpa(W,3)

更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by