solving system of non-linear equations
조회 수: 2 (최근 30일)
이전 댓글 표시
I have two equations and two unknowns, (a and b2). I am trying to find values of a and b2 that will make my two equation zero. Below you will find the code i used to do so. The code does not work. please assist me.
note : b2 can not go above 50 and a can not go below 50
clear all
h = 50;
sigma1 = 1000;
sigma2 = 1800;
sigma3 = 2000;
s2 = 800;
s3 = 1000;
kic = 1000;
pf= 1400;
s0 = 2* pf -sigma2 - sigma3;
for a=50:200
for b2=1:49
eq1(a,b2) = (s0(pnet)*(pi()/2))+s2*asin(b2/a)+s3*asin((h-b2)/a)-((sqrt(pi()))/(2*sqrt(a)))*(2*kic/sqrt(12));
eq2(a,b2) = s2*sqrt((a^2)-(b2^2))-s3*sqrt((a^2)-((h-b2)^2))-sqrt(a*pi())*(kic-kic);
end
if abs(eq1(a,b2))<1 || abs(eq2(a,b2))<1
solution1(pnet) = a;
solution2(pnet) = b2;
end
end
eq1(eq1==0)=NaN;
eq2(eq2==0)=NaN;
댓글 수: 1
John D'Errico
2017년 2월 22일
편집: John D'Errico
2017년 2월 22일
There is no need to write pi(). pi takes no arguments. So just write it as pi, with no () following.
Anyway, the code above is not even valid. s0 is a scalar variable that takes on the value -1000. Yet you are trying to index the scalar s0 with some unknown/unsupplied variable or function called pnet.
There are various recommendations I might make. Perhaps using a contour plot to resolve the solution, IF one or more solutions do exist. Or you could use a tool like fsolve. Both of these approaches are far better solutions than a brute force nested loop as you have done.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Systems of Nonlinear Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!