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 次查看(过去 30 天)
显示 更早的评论
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);
0 个评论
回答(1 个)
John D'Errico
2021-9-26
编辑:John D'Errico
2021-9-26
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([])
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);
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.)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numerical Integration and Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!