How to solve equations having product variables

3 Ansichten (letzte 30 Tage)
Yunji Seol
Yunji Seol am 31 Mär. 2018
Beantwortet: Manan Mishra am 3 Apr. 2018
I have 3 equations.
  • x+y+z=2
  • x+3y+4z=7
  • x-2y+3z+xy+yz+zy+xyz=6
When I search, many people use the "A\b" function, how should I write it in my case?
A = [ 1 1 1 0 0 0 0 0 ; 1 3 4 0 0 0 0 0; 1 -2 3 1 1 1 1 ];
b = [ 2; 7; 6];
I want to get value of x, y, z.
The above code is not correct, but I want to write it like that.
What function should be used to solve it?

Antworten (1)

Manan Mishra
Manan Mishra am 3 Apr. 2018
You can use the function fsolve to solve a system of non-linear equations.
Please refer the following link to know more about this function:
You can also refer the examples in the above link for a better understanding of the function.
The following steps might help you:
1. Convert the equations to the form F(x) = 0.
2. Write a function that computes the left-hand side of these three equations.
3. Save this code as a file on your MATLAB path.
4. Solve the system of equations starting at the given point.
function f = eqn(x)
f(1) = x(1)+x(2)+x(3)-2;
f(2) = x(1)+3*x(2)+4*x(3)-7;
f(3) = x(1)-2*x(2)+3*x(3)+x(1)*x(2)+x(2)*x(3)+x(3)*x(1)+x(1)*x(2)*x(3)-6;
end
Save this function as a file and execute the following code.
func = @eqn;
x0 = [0,0,0];
x = fsolve(func,x0)

Kategorien

Mehr zu 비선형 연립방정식 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!