Solve for a normaliztion constant in MATLAB

1 次查看(过去 30 天)
Hi, I have the following code:
if true
% code
end
syms h g x C n L p e E C m N
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))
prod=@(x)y(x).*z(x)*N^2
Nsol = solve(int(prod,x,0,2*pi)-1==0,N)
A=vpa(Nsol)
all constants are defined (not visible to save space), and I would like to solve for N, as can be seen in prod line, but this does not work.
This gives however:
Error in sym>tomupad (line 1233) x = funchandle2ref(x);
Error in sym (line 199) S.s = tomupad(x);
Error in sym/int (line 63) f = sym(f);
Error in Integral_eqn (line 15) Nsol = solve(int(prod,x,0,2*pi)-1==0,N)

回答(2 个)

Torsten
Torsten 2018-1-3
编辑:Torsten 2018-1-3
Does it work if you simply set
prod = y*z*N^2;
?
By the way: The result will be
N = +/- 1/sqrt(int(y*z,x,0,2*pi))
Best wishes
Torsten.
  2 个评论
Sergio Manzetti
Sergio Manzetti 2018-1-3
Didn't work for me, but I take your result for good! Thanks Torsten,
Torsten
Torsten 2018-1-3
What's the error message for this coding:
syms h g x C n L p e E C m N
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))
prod = N^2*y*z;
Nsol = solve(int(prod,x,0,2*pi)-1==0,N)
?
Best wishes
Torsten.

请先登录,再进行评论。


Birdman
Birdman 2018-1-3
Use the following:
syms h g y(x) z(x) C n L p e E C m N
y(x) = - (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(x) = - (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))
prod=y.*z.*N.^2
Nsol = solve(int(prod,x,0,2*pi)-1==0,N)
A=vpa(Nsol)

Community Treasure Hunt

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

Start Hunting!

Translated by