- #1

rsr_life

- 51

- 0

**fsolve**.

So, I have an equation

**L = K(x) - F(x,y)**. Given the values of L and y, I need to determine the value of x numerically.

So, here's what I've done:

**G(x) = L- K(x) + F(x,y)**

in the function m-file

**function [G] = g(x,y,L)**

I then need to evaluate G(x) numerically to find the values of x at which G(x) becomes 0. Thats my understanding of numerical determination.

So I use the fsolve command in Matlab this way

[x, fval] = fsolve(@g, x, options);

But the problem is that I need to pass multiple values of y, L and some initial estimate of x (that apparently fsolve requires) to find different values of x for different values of y. Matlab doesn't accept this. i.e. ideally I'd like to do something like

**for y=0:0.1:10**

[x, fval] = fsolve(@g(x,y,L), x, options);

end

where I can pass multiple values of y and L (array or for-loop) to find the values of x.

Can I do this? or do I need to declare Global variables and access y and L in function g that way?

Also, if I've no idea of what x looks like, how do I estimate an initial value?

Would appreciate your contributions to resolving this.

Thanks.