필터 지우기
필터 지우기

Solving system of nonlinear euations

조회 수: 4 (최근 30일)
Kashif
Kashif 2015년 1월 14일
댓글: Shoaibur Rahman 2015년 1월 15일
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+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/16).*y*z^2 +Mphi(n/16).*y*s^2+Mphi(n/16).*s*x^2+Mphi(n/16).*z*y^2+Ophi(n/16).*x*z^2+Ophi(n/16).*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개)

카테고리

Help CenterFile Exchange에서 Utilities for the Solver에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by