%% Several Cone Constraints
% To set up a problem with several second-order cone constraints, create an array of constraint objects. 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);

% Create the linear objective function vector.

f = [-1;-2;-4];

% Solve the problem by using the coneprog function.

[x,fval] = coneprog(f,socConstraints)

% Copyright 2020 The MathWorks, Inc.