Solving system of 9 nonlinear equaitons in 16 variables
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Sachchidanand Prasad
le 28 Nov 2022
Réponse apportée : Torsten
le 28 Nov 2022
I have a system of equations as follows:
I am not able to use fsolve as it says in the documentaiton that the number of variables should be as same as the number of equations. I found this on the MathWorks which says that it can be done with fsolve. Please let me know if it can be solved by any other method or by using fsolve. It will also suffice if I can know the solution exists.
I am writing the MATLAB code that I have written using fsolve.
f = @(x) [x(1)*x(9) + x(2)*x(12) + x(3)*x(15) - 13;
x(1)*x(10) + x(2)*x(13) + x(3)*x(16) - 15;
x(1)*x(11) + x(2)*x(14) - x(3)*(x(9) + x(13)) + 1;
x(4)*x(9) + x(5)*x(12) + x(6)*x(15) - 9;
x(4)*x(10) + x(5)*x(13) + x(6)*x(16) - 24;
x(4)*x(11) + x(5)*x(14) - x(6)*(x(9) + x(13));
x(7)*x(9) + x(8)*x(12) - x(15)*(x(1) + x(5)) - 7;
x(7)*x(10) + x(8)*x(13) - x(16)*(x(1) + x(5)) -2;
x(7)*x(11) + x(8)*x(14) + (x(1)+x(5))*(x(9)+x(13)) - 35];
A = zeros(1,9);
fsolve(f, A)
0 commentaires
Réponse acceptée
Torsten
le 28 Nov 2022
x0 = -10*ones(16,1);
AB = [13 15 -1;9 24 0;7 2 35];
options = optimset('TolFun',1e-16,'TolX',1e-16);
x = fmincon(@(x)fun(x,AB),x0,[],[],[],[],[],[],[],options);
A = [x(1) x(2) x(3);x(4) x(5) x(6);x(7) x(8) -(x(1)+x(5))]
B = [x(9) x(10) x(11);x(12) x(13) x(14);x(15) x(16) -(x(9)+x(13))]
A*B-AB
function obj = fun(x,AB)
A = [x(1) x(2) x(3);x(4) x(5) x(6);x(7) x(8) -(x(1)+x(5))];
B = [x(9) x(10) x(11);x(12) x(13) x(14);x(15) x(16) -(x(9)+x(13))];
M = A*B - AB;
M = M(:);
obj = sum(M.^2);
end
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Systems of Nonlinear Equations 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!