Hi Guys.. I need to print X values from intlinprog output from all 24 iterations as a matrix, when am trying to assign the values to A matrix its not happening. PLz help

2 views (last 30 days)
Manikanta Chennu
Manikanta Chennu on 26 Sep 2021
Commented: Manikanta Chennu on 27 Sep 2021
clc
[load_data,txt,raw] = xlsread('Load profile data.xlsx');
schedule=zeros(24,8);
for i=1:24
f=[12 8 9 10 0 0 0 0];
intcon=[5,6,7,8];
A=[ 1 0 0 0 -1080 0 0 0;
-1 0 0 0 360 0 0 0;
0 1 0 0 0 -540 0 0;
0 -1 0 0 0 180 0 0;
0 0 1 0 0 0 -540 0;
0 0 -1 0 0 0 180 0;
0 0 0 1 0 0 0 -108;
0 0 0 -1 0 0 0 360];
b=[0 0 0 0 0 0 0 0];
Aeq=[1 1 1 1 0 0 0 0];
beq=[load_data(i,2)];
lb=[0 0 0 0 0 0 0 0];
ub=[1080 540 540 1080 1 1 1 1];
X=intlinprog(f,intcon,A,b,Aeq,beq,lb,ub);
schedule(i,:)=X'; %% here am getting dimension error??????
end
disp(schedule);

Answers (1)

John D'Errico
John D'Errico on 26 Sep 2021
Edited: John D'Errico on 26 Sep 2021
Of course, we cannot answer your question in more depth, since you have not provided your data. But if we look at the screenshot you supplied, it tells us the left hand side of an assignment was 1x8. On the right hand side of the assignment the result was 0x0.
What size is an empty array?
size([])
ans = 1×2
0 0
But consider what intlinprog will return if no solution is found? Yes. An empty array. And then MATLAB will complain. In fact, it will complain for exactly that reason, with exactly that error message. For example...
schedule = zeros(24,8);
schedule(1,:) = zeros(0,0);
Unable to perform assignment because the size of the left side is 1-by-8 and the size of the right side is 0-by-0.
Do you KNOW that a solution ALWAYS exists for all such possible problems? (Clearly not, since in at least one case, no solution is found.)
  2 Comments
Manikanta Chennu
Manikanta Chennu on 27 Sep 2021
Do you KNOW that a solution ALWAYS exists for all such possible problems? (Clearly not, since in at least one case, no solution is found.... This satement solved my problem.. Thank you so much Mr. John

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!