Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Matlab Problem!!!
Date: Wed, 3 Dec 2008 09:44:57 -0500
Organization: The MathWorks, Inc.
Lines: 34
Message-ID: <gh6619$npo$1@fred.mathworks.com>
References: <6200318.1228278241565.JavaMail.jakarta@nitrogen.mathforum.org> <23500797.1228280941124.JavaMail.jakarta@nitrogen.mathforum.org> <gh5h9n$m1o$1@fred.mathworks.com>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1228315497 24376 144.212.105.187 (3 Dec 2008 14:44:57 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 3 Dec 2008 14:44:57 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
Xref: news.mathworks.com comp.soft-sys.matlab:504687



"Bjorn Gustavsson" <bjonr@irf.se> wrote in message 
news:gh5h9n$m1o$1@fred.mathworks.com...
> Matt <mcushi2@gmail.com> wrote in message 
> <23500797.1228280941124.JavaMail.jakarta@nitrogen.mathforum.org>...
>> I've tried many things.  I already have it saved as newton.m file.  And 
>> I'm trying multiple things in the M-File Configuration Box.  I've tried:
>>
>> x = 1;
>> f = [@(x)x.^2, @(x)2*x];
>> newton(f, 0.2);
>>
> In my current version of matlab (7.1) the above pattern doesn't work, 
> since you'd get a call along this line somewhere:
>
> val  = f(1)(12)
>
> As far as I recall the recommendation with arrays of function handles are 
> to use cell arrays:
>
> f = {@(x) (x.^2), @(x) (2*x)};

It depends on what the OP wants.  Rather than a cell array of function 
handles, I suspect he may want a function handle that returns an array:

f = @(x) [x.^2; 2*x];

Then something like f(5) would work.

-- 
Steve Lord
slord@mathworks.com