The number of rows in A must be the same as the number of elements of b.

1 次查看(过去 30 天)
n=3;
c=50;
a=500;
A=[1 0 0;0 1 0;0 0 1];
for j=1:n
F(j) = uicontrol('style','edit','units','pixels',...
'position',[c a 50 50],'fontsize',20,'string','');
c = c+60;
end
c = 50;
a = a-70;
for j=1:n
B(j) = uicontrol('style','edit','units','pixels',...
'position',[c a 50 50],'fontsize',20,'string','');
c = c+60;
end
c=50;
a=a-70;
for i=1:2
for j=1:n
a1(i,j) = uicontrol('style','edit','units','pixels',...
'position',[c a 50 50],'fontsize',20,'string','');
c = c+60;
end
c=50;
a=a-70;
end
for j=1:2
b1(j) = uicontrol('style','edit','units','pixels',...
'position',[c a 50 50],'fontsize',20,'string','');
c = c+60;
end
c=c+120;
a=500;
Aeq= nan(2,3);
btn1 = uicontrol('style','pushbutton','units','pixels',...
'position',[c a 170 50],'fontsize',20,'string','Lead Distance', ...
'Callback', 'for k = 1:n, f(k) = str2double(get(F(k),''string'')); end');
a=a-70;
btn2 = uicontrol('style','pushbutton','units','pixels',...
'position',[c a 170 50],'fontsize',20,'string','Capacity', ...
'Callback', 'for k = 1:n, b(k) = str2double(get(B(k),''string'')); end');
a=a-70;
btn3 = uicontrol('style','pushbutton','units','pixels',...
'position',[c a 170 50],'fontsize',20,'string','Alumina', ...
'Callback', 'for k = 1:n*2, Aeq(k) = str2double(get(a1(k),''string'')); end');
a=a-70;
btn4 = uicontrol('style','pushbutton','units','pixels',...
'position',[c a-70 170 50],'fontsize',20,'string','Plant Requirements', ...
'Callback', 'for k = 1:2, beq(k) = str2double(get(b1(k),''string'')); end');
b=transpose(b);
btn5 = uicontrol('style','pushbutton','units','pixels',...
'position',[c a-70 170 50],'fontsize',20,'string','Calculate', ...
'Callback', {@linprog f',A,b,Aeq,beq'});
Hii I am trying to run linprog by taking inputs from gui but its showing "The number of rows in A must be the same as the number of elements of b". But as it is obvious it is same. Please help!

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Programming and Mixed-Integer Linear Programming 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by