From: "deva " <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Solving an equation with no close analytical solution
Date: Sat, 20 Dec 2008 10:35:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 61
Message-ID: <giihon$t6b$>
References: <gifvtb$6tp$> <gigbvi$pfg$>
Reply-To: "deva " <>
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: 1229769303 29899 (20 Dec 2008 10:35:03 GMT)
NNTP-Posting-Date: Sat, 20 Dec 2008 10:35:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1646150
Xref: comp.soft-sys.matlab:508109

"John D'Errico" <> wrote in message <gigbvi$pfg$>...
> "deva " <> wrote in message <gifvtb$6tp$>...
> > Hi to all and thanks in advance for your help.
> > I have to solve an equation that writes as 
> > a=exp(x*c)*(exp((b-x)*c)-1)/(b-x)
> > The unknown is x while a,b and c are known
> > I have 5000 values for a while c and b are the same through each equation, this means that I need to find 5000 x.
> > In maple I can find a numerical solution with fsolve, but I have to do manually for each of the 5000 values (which takes a awful amount of time)
> > I would like to know if there is a way to find a numerical solution to this equation in matlab and to this in a loop that allows to use the array of 5000 values of a to create an array for the 5000 values of x.
> > 
> > I do know if that's clear, i have been struggling for this porblem for the latest three days.
> > So any help would be really greatly appreciated!!!
> > thanks again
> > a
> The simple answer is a loop using fzero, not fsolve.
> Fzero will be more robust for problems of one variable,
> if you are able to bracket the root.
> The more complex answer is to use arrayfun, which
> will solve the problem using an implicit loop. Still use
> fzero though.
> My next choice as an answer is to solve it as a batched
> problem in fsolve. Use the largescale method. Specify
> the pattern of the jacobian matrix through optimset.
> I discuss this style of solution in my optimization tips
> and tricks.
> You may need to verify the solutions for convergence,
> since some subproblems may possibly diverge. Go back
> and apply fzero to those subproblems only.
> HTH,
> John

Hi John,
thanks a lot for your message.
I have tried and I get the message
"??? Error using ==> fzero
FZERO cannot continue because user supplied function_handle ==> @(x) myfun(x,a,b,c)
failed with the error below.

Error: File: myfun.m Line: 5 Column: 1
Function definitions are not permitted at the prompt or in scripts. "

What I have done is 
function l=myfun(x,a,b,c)


 fzero(@(x) myfun(x,a,b,c),0.1);

thanks again