%% Obtain coneprog Dual Variables
% Create a second-order cone programming problem. To save time and memory, create the highest-index constraint first.

A = diag([1,2,0]);
b = zeros(3,1);
d = [0;0;1];
gamma = -1;
socConstraints(3) = secondordercone(A,b,d,gamma);
A = diag([3,0,1]);
d = [0;1;0];
socConstraints(2) = secondordercone(A,b,d,gamma);
A = diag([0;1/2;1/2]);
d = [1;0;0];
socConstraints(1) = secondordercone(A,b,d,gamma);
f = [-1;-2;-4];

% Solve the problem, requesting dual variables at the solution along with all other coneprog output..

[x,fval,exitflag,output,lambda] = coneprog(f,socConstraints);

% Examine the returned lambda structure. Because the only problem constraints are cone constraints, examine only the soc field in the lambda structure.

disp(lambda.soc)

% The constraints have nonzero dual values, indicating the constraints are active at the solution.
% Copyright 2020 The MathWorks, Inc.