multidimensional matrix optimization error
Show older comments
Hello everyone,
I have an optimization variable
y=optimvar('y',[4,1],'Type','integer','LowerBound',0,'UpperBound',1);
and I want to put this "y" into a matrix which have 4 time periods, so i created a multidimensional matrix as this:
yi=y([ 1 2 3 4; 2 2 3 4;3 3 3 4;4 4 4 4]);
yi(:,:,2)= y([ 1 2 3 4; 2 2 3 4;3 3 3 4;4 4 4 4]);
yi(:,:,3)= y([ 1 2 3 4; 2 2 3 4;3 3 3 4;4 4 4 4]);
yi(:,:,4)= y([ 1 2 3 4; 2 2 3 4;3 3 3 4;4 4 4 4]);
where the third dimension is about time, which I have 4 years in my problem. While I run this code in matlab it says this is an illegal assignment, could anyone help me with that?
Thank you!
4 Comments
dpb
on 20 Jul 2019
Never used it, but looks like you would need
y=optimvar('y',[4,4,4],'Type','integer','LowerBound',0,'UpperBound',1);
but that's guessing on syntax; most confusing description.
BOWEN LI
on 20 Jul 2019
>> whos yi
Name Size Bytes Class Attributes
yi 4x4x4 512 double
>>
yi is a 4x4x4 array...I don't follow what your intention really is, just what you created is above.
I also don't fully understand the doc with optimvar and how the problem setup would work so am just throwing darts here--and the crystal ball is dark.
BOWEN LI
on 21 Jul 2019
Accepted Answer
More Answers (0)
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!