Borrar filtros
Borrar filtros

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

3 visualizaciones (últimos 30 días)
Bondita Paul
Bondita Paul el 12 de Jul. de 2021
Respondida: Zuber Khan el 8 de Mayo de 2024
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?

Respuestas (1)

Zuber Khan
Zuber Khan el 8 de Mayo de 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

Categorías

Más información sobre Denoising and Compression en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by