From: "Steven Lord" <>
Newsgroups: comp.soft-sys.matlab
Subject: Re: finding complex root from nonlinear equations with complex arguments
Date: Wed, 20 May 2009 13:18:33 -0400
Organization: The MathWorks, Inc.
Lines: 39
Message-ID: <gv1e10$a7t$>
References: <> <> <gjqsf6$otg$> <gk5atm$16i$> <gv19el$jnf$>
Reply-To: "Steven Lord" <>
X-Trace: 1242839904 10493 (20 May 2009 17:18:24 GMT)
NNTP-Posting-Date: Wed, 20 May 2009 17:18:24 +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: comp.soft-sys.matlab:541318

"Venkat raman Thenkarai Narayanan" <> wrote in message 
> Hi,
>       I'd like to know how to pass constants from the command line for the 
> "LMFnlsq" function. For example, you've a function y = x^3 + *x^2 + 
> c2*x + c3 and i want to pass the values c1, c2 and c3 from the command 
> line rather than specifying in the file itself. I am finding that the 
> function is not flexible in that regard. Can you tell me what i need to do 
> if i want to play around with different constants input from the command 
> line?

After a bit of searching, I found that LMFnlsq refers to this File Exchange 

That looks like it has a fairly standard "function function" style 
interface.  I'd probably write my M-file something like:

function coeffs = findTheCoefficients(coeffVector)
% Call this like:
%     c = findTheCoefficients([2 3 4])
% for the problem y = x^3 + 2*x^2 + 3*x + 4

myObjectiveFunction = @(x) polyval([1 coeffVector], x);
coeffs = LMFnlsq(myObjectiveFunction, ...) % pass in whatever options you 

POLYVAL accepts a vector of polynomial coefficients and a value and 
evaluates the specified polynomial at that value.

Steve Lord