How to use lsqr matlab function to minimize a cost function?

1 回表示 (過去 30 日間)
Bondita Paul
Bondita Paul 2021 年 7 月 12 日
回答済み: Zuber Khan 2024 年 5 月 8 日
x=argmin(||(Ax-b)c||^2+||e(x-d)||^2), Where A is a mxn matrix, c,d,e are vectors. How to write this function using lsqr inbuilt matlab function?
x=lsqr(A,b,tol,maxit). Here how to insert value of c,d,e?

回答 (1 件)

Zuber Khan
Zuber Khan 2024 年 5 月 8 日
Hi,
I understand that you want to minimize the given cost function using "lsqr" method.
Note that 'lsqr(A,b)' attempts to solve the system of linear equations A*x = b for x using the Least Squares Method.
Now firstly, your optimzation problem can be seen as a combination of two least squares problems. However, "lsqr" cannot directly solve it in the given form because of the additional vectors 'c', 'd', and 'e', and the way they interact with 'x'.
A common approach to deal with additional linear terms in a least squares problem is to augment the matrix 'A' and vector 'b' to incorporate these terms, turning the problem into a standard form that "lsqr" can solve. However, this is not a straightforward approach since you would need to take care of the dimensionality and ensure that the resulting equation A*x = b consisting of augmented arrays 'A' and 'b', truly represents the original form of the problem.
Alternatively, a better way would be to use appropriate solvers like "fminunc" or "lsqnonlin" for your use case. For instance, the given problem can be tackled using "fminunc" as follows:
% Define the cost function
costFunc = @(x) norm((A*x - b)*c)^2 + norm(e*(x - d))^2;
% Initial guess for x
x0 = zeros(n, 1);
% Minimize the cost function
x = fminunc(costFunc, x0);
For more information related to "fminunc" solver, kindly refer to the following documentation link:
Further, in order to explore "lsqnonlin" solver, kindly refer to the documentation link mentioned below:
I hope this will resolve your query.
Regards,
Zuber

カテゴリ

Help Center および File ExchangeMathematics and Optimization についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by