# How to make a matrix compose by seperate optimization variables

2 views (last 30 days)
BOWEN LI on 2 Jul 2019
Edited: Matt J on 3 Jul 2019
Hi everyone,
I am thinking if it possible to put several optimizaiton variables into a matrix form. My optimization variable is defined by this syntax:
>> z1=optimvar('z1','Type','integer','LowerBound',0,'UpperBound',1)
>> z2=optimvar('z2','Type','integer','LowerBound',0,'UpperBound',1)
>> z3=optimvar('z3','Type','integer','LowerBound',0,'UpperBound',1)
zij=['z1','z2','z3';'z2','z2','z3';'z3','z3','z3']
It turns out that my 'zij' is a set of arrays not matrix. Anyone has idea about that? Thanks so much!

Matt J on 2 Jul 2019
This works fine, once you remove the quotes
>> zij=[z1,z2,z3; z2,z2,z3; z3,z3,z3];
>> showexpr(zij)
(1, 1)
z1
(2, 1)
z2
(3, 1)
z3
(1, 2)
z2
(2, 2)
z2
(3, 2)
z3
(1, 3)
z3
(2, 3)
z3
(3, 3)
z3
BOWEN LI on 3 Jul 2019
Hi, I think the dependent optimization variable you said "Zmatrix" is just what I want.
Because my goal is to let Z(1,2) and Z(2,1) have the same upperbound and lowerbound while Z(1,2) and Z(2,1) reference to the same independent variable z(2). So in this case, I can multiply 'Zmatrix' with the other matrix which I also index as [1 2 3; 2,2,3;3 3 3].
So, in this sense, Z(1,3),Z(3,1),Z(3,2), and Z(3,3) all reference to z(3) right?
Thank you so much!

### Categories

Find more on Choose a Solver in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!