%% Create Optimization Expression by Looping
% Use optimexpr to create an empty expression, then fill the expression in a loop.

y = optimvar('y',6,4);
expr = optimexpr(3,2);
for i = 1:3
    for j = 1:2
        expr(i,j) = y(2*i,j) - y(i,2*j);
    end
end
show(expr)

%
% Copyright 2012-2019 The MathWorks, Inc.