####运行代码有错误
怎么做才能运行?
clc; clear
% 输入数据
T = [48.7, 53.0, 61.3, 72.0, 48.7, 52.0, 64.0]; % T (cm)
W = [2000, 3000, 1000, 500, 4000, 2000, 1000]; % W (kg)
N = [8, 7, 9, 6, 6, 4, 8]; % Q (件)
L = 10.2; % 平板车长 (m)
maxWeight = 40000; % 最大重量(kg)
maxThickness = 302.7; % 最大厚度 (cm)
% 定义优化问题的变量
x = optimvar('x',7,'Type','integer','LowerBound',0);
% 定义目标函数
obj = L - sum(T'.*x)/100; % 减少空间浪费
% 定义约束
con1 = sum(W.*x) <= maxWeight;
con2 = sum(T(5:7).*x(5:7)) <= maxThickness; % 对 C5、C6 和 C7 的特殊限制
con3 = x <= N'; % 最大容量
problem = optimproblem('Objective',obj,'Constraints',[con1,con2,con3]);
[sol,fval,exitflag,output] = solve(problem);
disp('Optimal Number of Containers:')
disp(sol.x)
disp(['Waste Space: ' num2str(fval) 'm'])
Error using optim.internal.problemdef.ElementwiseOperator/checkIsValid
Argument dimensions 1-by-7 and 7-by-1 must agree.
Error in optim.internal.problemdef.Times/checkIsValid
Error in optim.internal.problemdef.Times.getTimesOperator
Error in .*
Error in untitled13 (line 17)
con1 = sum(W.*x) <= maxWeight;