Matlab help - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Matlab help

Superman1221Superman1221 Posts: 1Member
I am having trouble coding this problem. Any help would be appreciated.

Implement in a matlab .m file a function whose prototype is:

function [xroot,count] = secant( f, x0, tol, maxit)

This function should have a help section similar to newtn. Your function should be implemented so that the user can either provide just f and x0, using the default value of tol = 1.0e-8 and maxit = 20, or provide f, x0, and tol, using the default value of maxit = 20, or provide f, x0, tol, and maxit. The parameter f is a function handle to some function whose root is desired, and x0 is an initial guess. The optional parameters are tol: stopping tolerance for the iteration, and maxit: the maximum number of iterations allowed.

The function secant will attempt to find a root of f, xroot, using the secant method.

Use your secant function to find the equilibrium position of the spring-tension problem described in class and whose function file (equilibrium.m) would begin like this:

function y = equilibrium(x)

% computes the net force in the x-direction:

% y = 4*(sqrt(9+x^2) -3)
Sign In or Register to comment.