Writing and solving systems of non-linear equation
1 view (last 30 days)
Show older comments
Hi everybody!
I have learned how to use fsolve for systems of non-linear equations, but now I have a problem because the systems that I need to solve are very large ones (not very complicated though) so I would like to know if there is a way in MATLAB to write automatically the systems of equations from a general formula.
As an example, if I want to solve x + y - 4 = 0 & x*y - 4 = 0, I would just write:
function fcns = eqns(z)
fcns(1) = z(1) + z(2) - 4;
fcns(2) = z(1)*z(2) - 4;
end
However, if I want to solve a system whose equations are given by the formula, say, "z(k) = z(k)*z(k-p)" for k=1:100, I cannot write all equations explicitly in a short amount of time, so I would need some MATLAB functions to write them according to the formula. Is there a way to do it? Or, am I following the wrong approach for this kind of problem? Thank you very much!
2 Comments
Andrew Newell
on 21 Feb 2015
Sure, MATLAB has powerful tools for handling equations that can be expressed in terms of vectors and matrices. If you can give a better description of the equations you need to solve, we can help you with setting them up.
Answers (0)
See Also
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!