Path: news.mathworks.com!not-for-mail
From: "Rodney Thomson" <readmore@iheartmatlab.blogspot.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Matlab Problem!!!
Date: Wed, 3 Dec 2008 07:41:04 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 36
Message-ID: <gh5d6g$6vp$1@fred.mathworks.com>
References: <6200318.1228278241565.JavaMail.jakarta@nitrogen.mathforum.org>
Reply-To: "Rodney Thomson" <readmore@iheartmatlab.blogspot.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1228290064 7161 172.30.248.37 (3 Dec 2008 07:41:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 3 Dec 2008 07:41:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1430350
Xref: news.mathworks.com comp.soft-sys.matlab:504599


Matt <mcushi2@gmail.com> wrote in message <6200318.1228278241565.JavaMail.jakarta@nitrogen.mathforum.org>...
> I'm trying to run the program:
> 
> function [x,numIts]=newton(f,x)
> EPSILON = 1.0e-6;
> MAXITS  = 500;
> 
> for numIts=1:MAXITS
>   [y,yprime] = feval(f,x);
>   increment = y\yprime;
>   x = x - increment;
> 
>   if norm(increment)<EPSILON
>     break;
>   end
> end
> 
> But cannot seem to get it to run.  What commands do I need
> to enter to get this thing to run?!?!?!  Thank you for the
> help

Look up the help for feval as it DOES NOT DO WHAT YOU ARE TRYING IT TO DO!

It executes a MATLAB function, not a generic mathematic function. You need to wrap your mathematical function in a MATLAB function first:

>> eqtn = @(x)(x^2)
eqtn = 
    @(x)(x^2)
>> feval(eqtn, 4)
ans =
    16

Rod

--
http://iheartmatlab.blogspot.com