matlab에서 f를 최적화하는 함수가 있습니다.이 함수는 원하는 변수 x = (x (1), x (2))에 따라 다릅니다. 최적화 할 필요가없는 두 개의 매개 변수 인 n과 c, 즉 n과 c에 대한 값의 행렬을 가지고 있으며 각 n과 c에 대해 최적의 x 값을 찾고 싶습니다.함수 핸들을 통해 추가 인수를 전달하여 Matlab에서 최적화 수행
clear all;
clc;
close all;
[email protected](x,n,c)n*x(1)+(x(2)+3*c)/(x(1)+c);
for n=1:10
for c=1:20
x=zeros(length(n),length(c));
fun{n,c}[email protected](x)f(x,n,c);
options=optimset('Algorithm','interior-point')
x(n,c)=fmincon(fun{n,c},[0;0],[1 0;-1 0;0 1;0 -1],[40;0;40;0],[],[],[],[],[],options);
end
end
??? Subscripted assignment dimension mismatch.
Error in ==> forloop2 at 10
x(n,c)=fmincon(fun{n,c},[0;0],[1 0;-1 0;0 1;0
-1],[40;0;40;0],[],[],[],[],[],options);
Any helps? Thank you so much!