필터 지우기
필터 지우기

Writing a complicated equation in

조회 수: 9 (최근 30일)
Rebeca Miyar
Rebeca Miyar 2018년 8월 22일
답변: David Goodmanson 2018년 8월 24일
I'm trying to write a code for the function attached. The only parameter which isn't a constant is h_c. The problem of course is that h_c appears in both sides of the equation. The only mathematical way I found to overcome this problem is by using the Lambert W function, but I'm not sure how to make it work in matlab. Is there a way to write this type of equation and have matlab solve it?
  댓글 수: 5
Torsten
Torsten 2018년 8월 23일
My guess is that "f" stands for frequency, thus should be inside the "cos" function.
Rebeca Miyar
Rebeca Miyar 2018년 8월 23일
the f is for lattice mismatch, and is outside of the cos

댓글을 달려면 로그인하십시오.

답변 (1개)

David Goodmanson
David Goodmanson 2018년 8월 24일
Hello Rebeca,
Matlab does have a lambertw function, so you can use it to solve this.
First of all, since b is known, one can solve for x = h_c / b, in which case
x = C*(log(x)+1)
where C is the product of all the factors in front on the rhs of the equation, except not including the b in the numerator.
You didn't say whether C can be of either sign. Plotting both sides of the equation together for various values of C shows that for negative C there is one real solution, and there are no real solutions for 0<=C<1. The two curves are tangent for C=1 at the point x=1. For C>1 there are two real solutions, one with x<1 and one with x>1. You may well have worked out the algebra, and the two solutions are
C = 2; % example
e = exp(1);
f = @(x) C*(log(x)+1);
x1 = (-C)*lambertw( 0,-1/(C*e))
x2 = (-C)*lambertw(-1,-1/(C*e))
x = .1:.001:7;
plot(x,x,x,f(x),x1,f(x1),'o',x2,f(x2),'o')
Two get both solutions you need two branches of the lambertw function, 0 and 1.
For negative C, there is just the one eal solution x1.
To find roots numerically , the solver fzero is available
C = 2;
g = @(x) C*(log(x)+1) - x; % find zeros
e = exp(1);
x1f = fzero(g,[1/e,1])
x2f = fzero(g,[1,2*C^2])
This gives the same results as before. It helps to supply fzero with intervals that contain one root (that way you are sure to get both roots), and for this problem the hardest part was coming up with suitable intervals for x1 and x2. But for many fzero situations the interval is pretty clear.

카테고리

Help CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by