MATLAB: Need help creating a function m-file for the bisection method for the following equation…

bisectionbisection methodmechanical

I'm really stuck on an assignment that regards the bisection method. This is due to me missing all of my lectures for the module because I have transferred course from Chemical to Mechanical Engineering. I can't get help from within the University as it is outside of term-time now and I am back home.
I am having great difficulty with the following task for which I have been given these values:
k = 1; n = 0.6833; U = 1.0714; Pgrad = -3.333333…..
I am then given the following equation defining the pressure gradient in a pipe of radius 'R' (the only unknown in the equation):
Pgrad = -2k * ( ( U * (3n + 1) ) / ( n * R ^ (1 + 1/n) ) ) ^ n
Use the bisection method to determine an approximate value of R, with an absolute error of less than 1 x 10^-6.
I'm not expecting someone to come up with the whole m-file or anything, but any help whatsoever would be greatly appreciated. I've spent hours and hours trying to catch up with where I should be on the course and even resorted to watching videos on Youtube to see if any could help.
Even if people could just try and point me in the right direction.
Thanks
(Here is the question from the actual assignment sheet)

Best Answer

I recommend you carefully read the Wikipedia article at:
http://en.wikipedia.org/wiki/Bisection_method
The method requires that you first find two values a and b such that the function f(R ) whose root you are attempting to find has opposite signs for f(a) and f(b). For that purpose I advise you to make a plot of your f(R ) with varying R so you can see approximately where it crosses the zero point and thus how to set those initial starting values for a and b. For your looping until the error is less than 1e-6, you will need to use matlab's 'while' command to continue until that condition is satisfied. The above article gives a fairly clear description of how to proceed within the while-loop.
In Mathworks' File Exchange there are several contributions whose codes could possibly guide you to a solution if you get desperate. See the list at:
http://www.mathworks.com/matlabcentral/fileexchange/index?term=bisection&utf8=