Solving system of nonlinear euations

1 次查看(过去 30 天)
In mathematica we use the command NSolve[{x^2 + y^3 == 1, 2 x + 3 y == 4}, {x, y}, Reals] without needing any initial guess to solve a system of non-linear equations. I need the same command in Matlab to solve system of non-linear equations BUT without needing the initial guess. THANKS
  4 个评论
Sara
Sara 2015-1-14
I don't think you can. You'll have to use fsolve, which requires an initial guess. If it's a mathematical exercise, I'd go with an array of zeros; otherwise, if the eqn represent a physical system, you can use some reasonable values (e.g. mass is usually >= 0).
Kashif
Kashif 2015-1-15
Actually to use fsolve we need to make another m file for the function, in my case ceofficients of variables in equations depend on many other values in my program . Can we make function which is called by fsolve within the program.

请先登录,再进行评论。

采纳的回答

Shoaibur Rahman
Shoaibur Rahman 2015-1-14
syms x y
[x,y] = vpasolve(x^2 + y^3 == 1, 2*x + 3*y == 4, x,y)
  2 个评论
Kashif
Kashif 2015-1-15
I have used the above command but i am getting this error Expression or statement is incorrect--possibly unbalanced (, {, or [.
My Codes were the following
syms x y z s [x,y,z,s] = vpasolve(Aphi(n/8).*x+Bphi(n/8).*y+Aphi(n/8).*z+Bphi(n/8).*s^2+Ephi(n/8).*x^2+Ephi(n/8).*y^2+Ephi(n/8).*z^2+Ephi(n/8).*s^2+Iphi(n/8).*x*z+Jphi(n/8).*y*s+Kphi(n/8).*x*s+Kphi(n/8).*y*s+Mphi(n/8).*y*z^2 +Mphi(n/8).*y*s^2+Mphi(n/8).*s*x^2+Mphi(n/8).*z*y^2+Ophi(n/8).*x*z^2+Ophi(n/8).*x*s^2+Ophi(n/8).*z*x^2+Ophi(n/8).*z*y^2-Uphi(n/8).*x^2*z^2-Uphi(n/8).*x^2*s^2-Uphi(n/8).*y^2*z^2-Uphi(n/8).*y^2*s^2 ==Vphi(n/8), Aphi(n+n/8).*x+Bphi(n+n/8).*y+Aphi(n+n/8).*z+Bphi(n+n/8).*s^2+Ephi(n+n/8).*x^2+Ephi(n+n/8).*y^2+Ephi(n+n/8).*z^2+Ephi(n+n/8).*s^2+Iphi(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x*s^2+Ophi(n/16).*z*x^2+Ophi(n/16).*z*y^2-Uphi(n/16).*x^2*z^2-Uphi(n/16).*x^2*s^2-Uphi(n/16).*y^2*z^2-Uphi(n/16).*y^2*s^2 ==Vphi(n/16), , x,y,z,s)
Shoaibur Rahman
Shoaibur Rahman 2015-1-15
I see an extra comma (,) in the very last part of the code. ,,x,y,z,s --- remove one comma. It also seems that you have to define Aphi, Bphi........ with n

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by