help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble with fsolve


From: Adam C Powell IV
Subject: Re: Trouble with fsolve
Date: Fri, 28 Oct 2005 13:27:48 -0400

Thanks very much, this and a couple of other tricks got my script
working in octave!

On Thu, 2005-10-27 at 15:28 +0200, Shai Ayal wrote:
> you have to declare them global also inside your function:
> 
> function fval=myfunc(x)
>   global z
>   fval(1)=x(1)-z*x(1)*x(1);
> return;
> 
> Adam C Powell IV wrote:
> > On Tue, 2005-10-18 at 17:17 +0200, David Bateman wrote:
> > 
> >>Adam C Powell IV wrote:
> >>
> >>
> >>>Greetings,
> >>>
> >>>I'm trying to solve a system with a function of more than one parameter:
> >>>
> >>>[x,fval] = fsolve(@hello_calc,x_guess,options,z3,Param);
> >>>
> >>>where hello_calc is declared later in the same file:
> >>>
> >>>function [fval]=hello_calc(x,z3,Param)
> >>>
> >>>This works just fine in MATLAB, but in octave I get:
> >>>
> >>>error: evaluating for command near line 40, column 1
> >>>error: called from `hello' in file `hello.m'
> >>>
> >>>Can octave fsolve not deal with functions of more than one parameter?
> >>>That seems to be suggested by the "man page" for fsolve which comes up
> >>>after the error is displayed...
> >>>
> >>>Thanks,
> >>>-Adam
> >>> 
> >>>
> >>
> >>The syntax with function handles is not supported in the CVS. I wrote a 
> >>patch to support it which was a huge hack, which you can find at
> >>
> >>http://www.octave.org/mailing-lists/octave-maintainers/2004/627
> >>
> >>together with the explanation of why this is the wrong way to go.. Note 
> >>that the changes to "quad" were made. However daspk, dasrt, dassl, 
> >>fsolve, lsode and odessa weren't converted as the resulting code is an 
> >>ugly hack. The only real solution is to completely dump the existing 
> >>mess for these functions and reimplement it removing the underlying 
> >>fortran code.... So a workaround with global variables is the only way 
> >>this can be done at the moment in octave..
> > 
> > 
> > First, thanks for letting me know the state of octave in this regard.
> > 
> > I'm having trouble working around this though.  How do I declare global
> > variables?  Octave seems to be ignoring them, e.g. in the attached code.
> > 
> > If I try to declare it above the function (commented), octave throws a
> > different error...
> > 
> > Thanks,
> > -Adam
-Adam
-- 
GPG fingerprint: D54D 1AEE B11C CE9B A02B  C5DD 526F 01E8 564E E4B6

Welcome to the best software in the world today cafe!
http://www.take6.com/albums/greatesthits.html



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]