How to solve a system of nonlinear equations with 3 unknowns, 2 equations but multiple sets of parameters

1 view (last 30 days)
Hi,
I am trying to solve for 3 unknown variables (say a,b,c) using 2 nonlinear equations (F1,F2). Normally this would be impossible but I also have an unspecified number (at least 2) of data sets containing parameters (e.g. (p1, q1), (p2, q2), ...) which essentially give me enough equations to solve for the 3 unknowns.
I have set up a function file containing the 2 equations (set equal to zero) with the aim of using the fsolve function. Is it possible to pass my function into fsolve with multiple parameter sets? i.e. something like:
x = fsolve([@func(p1,q1), @func(p2,q2)] , x0)
For that matter is it possible to pass to fsolve a function that needs inputs other than the initial guess x0?

Accepted Answer

Matt J
Matt J on 2 Apr 2014
Edited: Matt J on 2 Apr 2014
You should define your equation function, fun, and pass it to FSOLVE as follows,
fun=@(x) masterfunc(x,pqData);
fsolve(fun,x0)
where pqData contains the pi and qi data in some form (e.g., as fields of a struct or an array with all the pi and qi concatenated together). The pi,qi data will then be available for use inside masterfunc. As usual, the output of masterfunc should be vector-valued, but you want it to return an element for all of your equations: not just the two equations F1,F2, but the additional equations arising from the pi,qi as well.

More Answers (0)

Categories

Find more on Systems of Nonlinear Equations in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!