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
  댓글 수: 2
Birdman
Birdman 2018년 1월 4일
You mean there is an error or something else?
Sergio Manzetti
Sergio Manzetti 2018년 1월 4일
Sorry. There was an error, but related to vpa(W). Removing this makes it work, although it looks horribly long.

댓글을 달려면 로그인하십시오.

채택된 답변

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