matlab,运行代码,出现以下错误:the following error occurred converting from cvx to double。
x = rand(1,0);
for i = 1:10
cvx_begin
variable u(9);
for k = 1 : 9,
U(k) = sqrt( x(i) + u(k) );
end
minimize( -( sum(U) ) )
u > zeros(1,9)
cvx_end
end
上述代码需要修改为:
x = rand(1,0);
for i = 1:10
cvx_begin
variable u(9);
expression U(1,9)
for k = 1 : 9,
U(k) = sqrt( x(i) + u(k) );
end
minimize( -( sum(U) ) )
u > zeros(1,9)
cvx_end
end
参考:https://www.cse.iitb.ac.in/~cs709/notes/code/cvx/doc/basics.html