Solving Nonlinear Matrix Equation
1 次查看(过去 30 天)
显示 更早的评论
I have an equation of the form
where A= positive definite symmetrix matrix (2 by 2), X is data matrix of dimensions (N by 2) and mu is a vector (1 by 2). Ki are scaler values and P is a constant. I want to use fsolve to solve for mu.
I am using the script as below
K_values in the code is an array that contains the values of each Ki.
data in the code is a ( N by 2 ) matrix of values that is passed on to the script below
The matrix A is calculated before running the script. The only unknown is the vector mu.
fsolve returns an error: Not enough input arguments
Any insight into solving this is highly appreciated.
syms X [length(data) 2]
syms mu [1 2]
syms K
T=subs(trace(inv(A)*(X-mu)'*(X-mu))^(P),X,data);
L1=subs(K*T,{K},{[K_values]});
fun1=matlabFunction(sum(L1));
mu0=[1;1];
options = optimoptions('fsolve','Display','none');
mu=fsolve(fun1,mu0,options);
0 个评论
采纳的回答
Walter Roberson
2021-11-30
fun1=matlabFunction(sum(L1));
That is going to produce a function with two inputs, mu1 and mu2. fsolve() only provides one input as a vector.
fun1=matlabFunction(sum(L1), 'vars', {mu} );
3 个评论
Walter Roberson
2021-11-30
编辑:Walter Roberson
2021-11-30
When I scan over the default algorithm at https://www.mathworks.com/help/optim/ug/equation-solving-algorithms.html#f51372 the use of the \ operator hints to me that your function needs to return a square matrix to solve the equations properly but I could be misreading.
The default algorithm was chosen because it was designed for nonlinear problems. However it is not always appropriate. To avoid seeing warning message, pass an options structure telling the code to use a different algorithm.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Particle & Nuclear Physics 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!