Solve for a normaliztion constant in MATLAB

1 回表示 (過去 30 日間)
Sergio Manzetti
Sergio Manzetti 2018 年 1 月 3 日
コメント済み: Birdman 2018 年 1 月 3 日
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)
  2 件のコメント
Sergio Manzetti
Sergio Manzetti 2018 年 1 月 3 日
Thanks Birdman, it gave the result. Quite a horrible one ! Thanks!
Birdman
Birdman 2018 年 1 月 3 日
If it did, can you accept the answer?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeNumeric Solvers についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by