- Evaluate your function at the endpoints of your interval to make sure one is positive and the other is negative.
- If both function values have the same sign, you need to adjust your interval. You can either widen the interval or choose different starting points based on your knowledge of the problem.
- If possible, plot the function over a range of b values to visually inspect where the sign change might occur. This can help you choose a better interval for fzero.
Using a function within fzero
11 views (last 30 days)
Show older comments
I am trying to find the value of b for where Smax*F(b)*sqrt(b/0.4) - Kic = 0.
F(b) is a function which gives me an interpolated value depending on b.
The code lines with my interval and where i call fzero look like this:
est_bc = [1e-6 r];
bc = fzero(@(b) Smax*F(b)*sqrt(b/0.4)-Kic, est_bc);
This gives me Error using fzero (line 290)
The function values at the interval endpoints must differ in sign.
Very grateful for answers!
0 Comments
Answers (1)
Shubham
on 15 Feb 2024
Hi Simon,
The error you're encountering indicates that the function you're trying to find the root of does not cross the x-axis within the interval you've specified. In other words, the function Smax*F(b)*sqrt(b/0.4)-Kic must have different signs (one positive and one negative) at the two endpoints of your interval est_bc for fzero to work. This is a requirement for the bisection method, which is part of the algorithm that fzero uses to find zeros.
To resolve the error, you need to ensure that the interval you provide to fzero contains a sign change. Here are some steps you can take:
0 Comments
See Also
Categories
Find more on Optimization in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!