I have a linear program in the MPS file format listing all the rows, columns, right-hand sides, etc. I can read that in Matlab and solve it using linprog. However, it seems there is no easy way to do sensitivity analysis for the right-hand side coefficients. I have to do the sensitivity analysis in Matlab as no other software is available. I would appreciate it if you could refer me to some ways I can accomplish that in Matlab.


1 Answer 1


As documented at https://www.mathworks.com/help/optim/ug/linprog.html, linprog returns the Lagranage multipliers via the optional 5th output argument, lambda. What are called Lagrange Multipliers by linprog and in Nonlinear Programming (optimization) are more usually called dual values in Linear Programming. So perhaps that is why you did not realize linprog provides them.

[x,fval,exitflag,output,lambda] = linprog(___) additionally returns a structure lambda whose fields contain the Lagrange multipliers at the solution x.

lambda is a structure which contains the fields


for lower bounds, upper bounds, equality constraints, and inequality constraints respectively.

  • $\begingroup$ I found the lambda which after I run the linprog routine shows a structure. However when I try to retrieve data like lambda.eqlin, it says the field eqlin doesn't exist. $\endgroup$
    – S_Scouse
    Commented Mar 6, 2020 at 1:40
  • $\begingroup$ Please show your code. If you just type lambda at the command line, you should see what the fields are. Any ffeld which doesn't have any of that type of constraint, will be empty. If you have lb, lambda.lb should be non-empty. If no equality constraints, then lambda.eqlin will be empty, etc. $\endgroup$ Commented Mar 6, 2020 at 3:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.