Matlab function

조회 수: 3 (최근 30일)
Liber-T
Liber-T 2011년 6월 20일
I need to solve a problem, here are my need:
-To find the zeros of a function
-The function is complex
-The zeros are complex
-The function is nonlinear
-I know the approximate place of the zero I'm searching
-I need to bound the search of the zero.
The function I've tried and does not work:
-fsolve (I can't bound the search and sometimes doesn't give me what I want)
-fzero(doesn't work at all)
-solve(doesn't work at all)
Just write the function I could use to find zeros please.

채택된 답변

Walter Roberson
Walter Roberson 2011년 6월 20일
Supply it with a vector of length 2, and internally construct x = xin(1) + 1i*xin(2), and calculate the complex result. Output the vector of length 2 which is real() and imag() of that result. The constraints you would supply would be the bounds on the real and imaginary parts (expressed as real numbers.)
  댓글 수: 4
Matt Fig
Matt Fig 2011년 6월 21일
I see your post of the function in another question, but you haven't told us many of the variables in that function. Why not post the COMPLETE function, with all variables defined, so that we can copy and paste it into MATLAB and it will work? For example, your function has a variable 'y' and a variable 'ne0' in it, which you have not defined. Is e equal to the exp(1)?
Liber-T
Liber-T 2011년 6월 22일
http://www.mathworks.com/matlabcentral/answers/9756-solve-det-and-ode-faster
I've posted everything here.

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

추가 답변 (2개)

the cyclist
the cyclist 2011년 6월 20일
For a complex zero, both the real and imaginary parts must be zero, and you can take advantage of this.
I believe you can use fzero() to do this, by separately solving for the real and imaginary zeros. For example, suppose your function is f(x) = x - i. Then,
fr = @(x) real(x - i)
fi = @(x) imag(x - i)
x0r = fzero(fr,3)
x0i = fzero(fi,3i)
You don't specify the bounds, but you do have the initial guess to get close to the zero. (Here, I just arbitrarily set my initial guess to "3" for both the real and imaginary parts.)
I hope this helps.
  댓글 수: 8
the cyclist
the cyclist 2011년 6월 21일
Your last statement is true, but it is not what I meant to propose. I did not mean:
real(f(xr))=0 and imag(f(xi))=0,
but rather
real(f(x)) = 0 and imag(f(x))=0.
Note the different arguments. These two statement, taken together, are equivalent to your f(xr+i*xi)=0+0i.
However, I think you are absolutely correct that my proposed solution will not work with the function as you describe it. But will any MATLAB function really handle all the branch cuts, etc, well?
Walter Roberson
Walter Roberson 2011년 6월 22일
I do not know how well MATLAB functions handle branch cuts.
Your sample algorithm solves for real(f(xr))=0 and imag(f(xi))=0. If there are multiple zeros on either the real or imaginary axis (as is likely) then finding the place the zeros coincide would require looping with careful manipulation of the intervals... and some work to generate new intervals as the signs of the function must be different at the two interval endpoints for fzero (it isn't as easy as saying "search 0 to 1; now search 1 to 2".)

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


Matt Fig
Matt Fig 2011년 6월 20일
If you have an explicit function of one variable, you might have luck with a Newton's method root finder.

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by