Solve for a normaliztion constant in MATLAB

1 view (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 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)

Answers (2)

Torsten
Torsten on 3 Jan 2018
Edited: Torsten on 3 Jan 2018
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 Comments
Sergio Manzetti
Sergio Manzetti on 3 Jan 2018
Didn't work for me, but I take your result for good! Thanks Torsten,
Torsten
Torsten on 3 Jan 2018
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.

Sign in to comment.


Birdman
Birdman on 3 Jan 2018
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)
  2 Comments
Sergio Manzetti
Sergio Manzetti on 3 Jan 2018
Thanks Birdman, it gave the result. Quite a horrible one ! Thanks!
Birdman
Birdman on 3 Jan 2018
If it did, can you accept the answer?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!