Solve for a normaliztion constant in MATLAB

1 Ansicht (letzte 30 Tage)
Sergio Manzetti
Sergio Manzetti am 3 Jan. 2018
Kommentiert: Birdman am 3 Jan. 2018
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)

Antworten (2)

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

Melden Sie sich an, um zu kommentieren.


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

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by