Solving system of 9 nonlinear equaitons in 16 variables
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Torsten
2022-11-28
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 个评论
更多回答(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!