Re: finding complex root from nonlinear equations with complex arguments
- From: "Venkat raman Thenkarai Narayanan" <thavil@xxxxxxxxx>
- Date: Wed, 20 May 2009 18:40:17 +0000 (UTC)
It didnt work out since LMFnlsq is written a bit differently (example given in the thread). LMFnlsq expects an equation file input ('res' in the example) But, what if the function isnt a polynomial and suppose i had y = c1*log(x) + c2/sinh(x) + c3*cosh(x).. I cant use polyval here.. My question is how would you have to modify the 'res' file in the example given by Miroslav to get c1, c2 and c3 from the command prompt rather than them being defined in the file itself. Kindly let me know.
Regards,
Venkat
"Steven Lord" <slord@xxxxxxxxxxxxx> wrote in message <gv1e10$a7t$1@xxxxxxxxxxxxxxxxxx>...
.
"Venkat raman Thenkarai Narayanan" <thavil@xxxxxxxxx> wrote in message
news:gv19el$jnf$1@xxxxxxxxxxxxxxxxxxxxx
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@xxxxxxxxxxxxx
- Follow-Ups:
- Re: finding complex root from nonlinear equations with complex arguments
- From: Miroslav Balda
- Re: finding complex root from nonlinear equations with complex arguments
- References:
- Re: finding complex root from nonlinear equations with complex arguments
- From: Venkat raman Thenkarai Narayanan
- Re: finding complex root from nonlinear equations with complex arguments
- From: Steven Lord
- Re: finding complex root from nonlinear equations with complex arguments
- Prev by Date: Re: Running m-file within m-file
- Next by Date: Re: how to display an array in desired format
- Previous by thread: Re: finding complex root from nonlinear equations with complex arguments
- Next by thread: Re: finding complex root from nonlinear equations with complex arguments
- Index(es):
Relevant Pages
|