Path: news.mathworks.com!not-for-mail From: "Steven Lord" <slord@mathworks.com> 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$1@fred.mathworks.com> References: <046c08c7-878f-4967-bab1-41273a92bcbd@r2g2000vbp.googlegroups.com> <f5f45956-b72f-4637-abec-c6ad168c231c@u14g2000yqg.googlegroups.com> <gjqsf6$otg$1@fred.mathworks.com> <gk5atm$16i$1@fred.mathworks.com> <gv19el$jnf$1@fred.mathworks.com> Reply-To: "Steven Lord" <slord@mathworks.com> NNTP-Posting-Host: lords.dhcp.mathworks.com X-Trace: fred.mathworks.com 1242839904 10493 144.212.105.187 (20 May 2009 17:18:24 GMT) X-Complaints-To: news@mathworks.com 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: news.mathworks.com comp.soft-sys.matlab:541318 "Venkat raman Thenkarai Narayanan" <thavil@yahoo.com> wrote in message news:gv19el$jnf$1@fred.mathworks.com... > 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 submission: http://www.mathworks.com/matlabcentral/fileexchange/17534 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 want POLYVAL accepts a vector of polynomial coefficients and a value and evaluates the specified polynomial at that value. -- Steve Lord slord@mathworks.com