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

1 Ansicht (letzte 30 Tage)
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
  2 Kommentare
Birdman
Birdman am 4 Jan. 2018
You mean there is an error or something else?
Sergio Manzetti
Sergio Manzetti am 4 Jan. 2018
Sorry. There was an error, but related to vpa(W). Removing this makes it work, although it looks horribly long.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

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

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by