Insights Blog
-- Browse All Articles --
Physics Articles
Physics Tutorials
Physics Guides
Physics FAQ
Math Articles
Math Tutorials
Math Guides
Math FAQ
Education Articles
Education Guides
Bio/Chem Articles
Technology Guides
Computer Science Tutorials
Forums
Intro Physics Homework Help
Advanced Physics Homework Help
Precalculus Homework Help
Calculus Homework Help
Bio/Chem Homework Help
Engineering Homework Help
Trending
Featured Threads
Log in
Register
What's new
Search
Search
Search titles only
By:
Intro Physics Homework Help
Advanced Physics Homework Help
Precalculus Homework Help
Calculus Homework Help
Bio/Chem Homework Help
Engineering Homework Help
Menu
Log in
Register
Navigation
More options
Contact us
Close Menu
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Forums
Homework Help
Engineering and Comp Sci Homework Help
MATLAB Script for Bisection Method
Reply to thread
Message
[QUOTE="sandy.bridge, post: 4973549, member: 356724"] [h2]Homework Statement [/h2] Not really for homework, but it is a script I am working on. It involves utilizing the Bisection Method for solving equations in one variable. However, I cannot seem to get it to work properly. It seems to enter the while loop and become stuck their. When I execute it by hand, it appears to work, but obviously there is some sort of code fallacy that I am not seeing. [h2]The Attempt at a Solution[/h2] [CODE] function bisection(F, a1, b1, e) %F represents the function we are analyzing %F must be passed into the function as a string %i.e., F='x^2+3*x'; %[a1,b1] represents the interval in which the zero exists %e represents the desired tolerance p1=(a1+b1)/2; p2=0; x=p1; f=eval(F); if f == 0 p1 else while abs(p1-p2)-e >= 0 p1=(a1+b1)/2; x=a1; F1=eval(F); x=p1; F2=eval(F); if F1*F2 < 0 b1=p1; else a1=p1; end p2=a1+b1/2; end p2 end end [/CODE] [/QUOTE]
Insert quotes…
Post reply
Forums
Homework Help
Engineering and Comp Sci Homework Help
MATLAB Script for Bisection Method
Back
Top