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

2 views (last 30 days)
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 Comments
Sergio Manzetti
Sergio Manzetti on 4 Jan 2018
Sorry. There was an error, but related to vpa(W). Removing this makes it work, although it looks horribly long.

Sign in to comment.

Accepted Answer

More Answers (0)

Community Treasure Hunt

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

Start Hunting!