Solving Nonlinear Matrix Equation

1 次查看(过去 30 天)
I have an equation of the form
A=positive definite symmetric matrix
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);

采纳的回答

Walter Roberson
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
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.
AAQIB PEERZADA
AAQIB PEERZADA 2021-11-30
Thanks Mr. Walter. It is now clear to me. Appreciate your help.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Particle & Nuclear Physics 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by