help-octave
[Top][All Lists]
Advanced

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

Re: Sending parameters to FSOLVE?


From: Mario Storti
Subject: Re: Sending parameters to FSOLVE?
Date: Tue, 29 Oct 1996 09:42:01 -0300

>>>>> On Tue, 29 Oct 96 14:17:32 +0100, "Bernt Nilsson" <address@hidden> said:


:> Hello all, Is there a way to send parameters to FSOLVE like there
:> is in MATLAB (i.e.  fsolve('func',...,p1,p2,p3...))?

:> It is a bit awkward to rewrite the m-file func.m everytime I want
:> to call it with a different value for a parameter.

:> Thanks for any input on this!

:> Sincerely, Bernt

:> Bernt J Nilsson email : address@hidden FOA, Inst. 65 tel : +46 8
:> 706 3611 S-172 90 Stockholm, Sweden FAX : +46 8 706 3543

>From the info documentation, I don't see that you can pass arguments
that way, but you can send parameters declaring them as "global". For
instance:

=====================================================
# This is the main code
(...)
# declaring my_internal_parameter as global
global my_internal_parameter

my_internal_parameter=0.001;
(...)

solution=fsolve("my_residual",...
(...)


function my_residual(x)
# The global declaration must be present also in the called function
global my_internal_parameter

# I can use "my_internal_parameter" even if it's not passed as
# argument! :-) 
f=my_internal_parameter;

endfunction
========================================================

Hope this helps

Mario

%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%%%%<>%%%
Mario Alberto Storti               | Fax: (54)(42) 55.09.44               |
Grupo de Tecnologia Mecanica       | Tel: (54)(42) 55.91.75               |
INTEC, Guemes 3450 - 3000 Santa Fe | http://venus.unl.edu.ar/gtm-eng.html |
Argentina                          | Home: Gob. Vera 3161                 |
Reply: address@hidden  |       (54)(42) 55.00.23              |


reply via email to

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