L1 Norm for a linear system

27 views (last 30 days)
EK
EK on 31 Jan 2012
Hi All,
I am trying to write an m-file for a function that returns L1 norm for a linear system using linprog (linear programming). I wrote the code below but it’s not working. I don’t know how to declare x as an unknown vector variable. The 2nd line gives me an error message which states “Not enough input arguments.”
Any help is highly appreciated and thanks in advance. EK
function n = lpaxb(Aeq,beq
n = norm((Aeq*x-beq),1)
x = linprog('lpaxb.m', n, A, b, Aeq,beq)
End

Answers (1)

Walter Roberson
Walter Roberson on 31 Jan 2012
I see no evidence in the current documentation that linprog can be invoked with a string as its first argument.
If the string is intended to represent a "solver", then you need to pass in a problem structure, which is a structure with fields listed in the documentation under "Input Arguments". Note that if the string is a solver, it should be a function name, not the name of a .m file. With the lack of information about the "solver" field, it could be that "solver" needs to be literally 'linprog' .
I see no input field that I can match to your "n". If your "n" is intended to be a parameter to your chosen solver, then I cannot tell from the documentation whether there is a way to pass it in explicitly.
  2 Comments
EK
EK on 31 Jan 2012
First of all, thank you for your input. Let me say at the outset that I am new to Mat lab and have very little experience with it. The code I posted was my best imitation of an m-file to generate a simple m-file that calculates L-1 for a linear equality system of equations. I know my variables are not well defined and correctly passed in.
I thought if I execute n=lpaxb(Aeq, beq), then it passes the two variables to n, the 2nd statement, as the objective function, which in turn passes it to x which returns the solution in terms of L-1
I know I have a problem with the 2nd statement that I don’t know how to fix. It seems to me if that statement is correct, then the third statement is correct judging from what I read about linprog. Any modification of suggestion of my code is highly appreciated. Thanks again. EK
Walter Roberson
Walter Roberson on 31 Jan 2012
You cannot use linprog() to minimize functions such as lpaxb. The first argument you pass to linprog() must be a vector or matrix. The parameter will be matrix-multiplied by the current vector of values ("x") and linprog() will be attempting to find the "x" vector that makes the output result zeros.
I do not know if there are useful alternatives designed for linear programming. You might have to use a minimizer such as fmincon().

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!