> Dear all,
>
> I am struggling a little with fsolve when it comes to
> applying using a range of parameters.
> I written a function file that goes like this:
>
> function F=myfunction(x, a,b,c,d) % where
> x=(x(1),x(2)) and a,b,c are parameters
>
> F=[ x(1)^2 +a *x(2)+ b./(1x(1));
> x(2)^2 +c *x(1)+ b./(1x(2))]
> end
>
> % above is just an example.
>
> IN the main file I define the parameters and look for
> the zeros of the function:
> a=0.1
> b=0.3
> c=0.9
> x0=[0.1, 0.2]
>
> myf=@(x) myfunction(x,a,b,c)
> x= fsolve(myf, x0)
>
> AND THE PROGRAM WORKS!
>
> BUT:
>
> I want to find solutions for a range of the parameter
> c (for example):
> c=0.1:0.01:0.99
>
> and I would like this solutions to be stored in
> matrix, so that I can plot x(1) and x(2) against c ,
> to see how the solution varies with the parameter.
>
> I have tried many things, including:
>
> for i=1:size(c,2)
> myf(i) =@(x) myfunction(x,a,b,c(i))
> x(i)=fsolve(myf(i),x0)
>
> end
for i=1:size(c,2)
ci = c(i)
x = fsolve(@(x) myfunction(x,a,b,ci),x0)
x1(i) = x(1)
x2(i) = x(2)
end
should work, I guess.
> but it doesnt work.
> HOW DO I STORE THE SOLUTIONS FOR ALL THE myf(i)'s
> THAT I AM INTERESTED IN?
>
> thanks a lot
>
> Mary
>
> p.s I have a matlab 7.0.6...if this makes any
> difference....
