Effacer les filtres
Effacer les filtres

How to solve equations having product variables

2 vues (au cours des 30 derniers jours)
Yunji Seol
Yunji Seol le 31 Mar 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?

Réponses (1)

Manan Mishra
Manan Mishra le 3 Avr 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)

Catégories

En savoir plus sur 비선형 연립방정식 dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!