当我运行代码时,它会在标记的行中使用vertcat显示错误。它是什么意思以及如何改变它?
f = [-10 -20 -40 -10 -10 80 70 90];
A = [ 1 1 2 1 3 0 0 0 -----> vertcat error
2 1 3 2 2 0 0 0
1 2 1 1 0 0 0 0
-1 0 0 0 0 1 1 1
0-1 0 0 0 1 1 1
0 0-1 0 0 1 0 0
0 0 0-1 0 0 1 0
0 0 0 0-1 0 0 1];
b = [800 600 900 0 0 0 0 0];
ub = [inf inf inf inf inf 90 57 93];
lb = zeros(8,1);
[x fval]=linprog(-f,A,b,[],[],lb,ub);
答案 0 :(得分:1)
A
遗漏了一些空格。这应该有效:
A = [ 1 1 2 1 3 0 0 0;
2 1 3 2 2 0 0 0;
1 2 1 1 0 0 0 0;
-1 0 0 0 0 1 1 1;
0 -1 0 0 0 1 1 1;
0 0 -1 0 0 1 0 0;
0 0 0 -1 0 0 1 0;
0 0 0 0 -1 0 0 1]
A =
1 1 2 1 3 0 0 0
2 1 3 2 2 0 0 0
1 2 1 1 0 0 0 0
-1 0 0 0 0 1 1 1
0 -1 0 0 0 1 1 1
0 0 -1 0 0 1 0 0
0 0 0 -1 0 0 1 0
0 0 0 0 -1 0 0 1