Effacer les filtres
Effacer les filtres

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

3 vues (au cours des 30 derniers jours)
Bondita Paul
Bondita Paul le 12 Juil 2021
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?

Réponses (1)

Zuber Khan
Zuber Khan le 8 Mai 2024
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

Catégories

En savoir plus sur Denoising and Compression dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by