solving system of non-linear equations

2 Ansichten (letzte 30 Tage)
erhamah alsuwaidi
erhamah alsuwaidi am 22 Feb. 2017
Bearbeitet: Walter Roberson am 22 Feb. 2017
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 Kommentar
John D'Errico
John D'Errico am 22 Feb. 2017
Bearbeitet: John D'Errico am 22 Feb. 2017
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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Systems of Nonlinear Equations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by