Borrar filtros
Borrar filtros

Solve for a normaliztion constant in MATLAB

1 visualización (últimos 30 días)
Sergio Manzetti
Sergio Manzetti el 3 de En. de 2018
Comentada: Birdman el 3 de En. de 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)

Respuestas (2)

Torsten
Torsten el 3 de En. de 2018
Editada: Torsten el 3 de En. de 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 comentarios
Sergio Manzetti
Sergio Manzetti el 3 de En. de 2018
Didn't work for me, but I take your result for good! Thanks Torsten,
Torsten
Torsten el 3 de En. de 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.

Iniciar sesión para comentar.


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

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by