[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fsolve and parameter dependent functions
From: |
Ivan Sutoris |
Subject: |
Re: fsolve and parameter dependent functions |
Date: |
Wed, 10 Jun 2009 16:58:49 +0200 |
On Wed, Jun 10, 2009 at 3:57 PM, Kenneth Duncan
Strouts<address@hidden> wrote:
> Say I have a set up like this;
>
> function y = f(x)
> ... stuff ...
> endfunction
>
> Then I can call fsolve("f",init) with init specifying initial
> conditions. And it works really nicely.
>
> However what if the function is to include a parameter,
>
> function y = f(x,p)
> ... stuff ...
> endfunction
>
> I want to specify p *when I call* fsolve. Is this possible? One
> could conceivably pass p through initial conditions and treat it as a
> variable, however I don't want to do this! Is there a cleaner way to
> do it?
>
> Thanks!
You can use anonymous function:
par = 1; % or whatever you need
solfun = @(x) f(x, par);
x = fsolve(solfun, init)
Regards
Ivan Sutoris