For loop in function
조회 수: 1 (최근 30일)
이전 댓글 표시
I tried to create a function with a for loop inside. When I try to use this function with the function handle some errors occur (when I just type it in the command window it works). But no matter what I try the error: Not enough input arguments always stays.
function y = fun_BSB(x,c_CSB_KA,c_AFS_KA,i_CSB_oTS)
for j=1:32
y(j)=0.625*(c_CSB_KA(j)-c_AFS_KA(j)*i_CSB_oTS(j)*x(1)*(1-x(2))-c_CSB_KA(j)*x(3));
end
end
Next Script:
fun=@fun_BSB;
x0=[0.02,0.02,0.035];
weight = abs(c_BSB5_KA);
for k=1:length(c_BSB5_KA)
[x,fval] = fgoalattain(fun,x0,c_BSB5_KA(k),weight(k));
ak(k,1:3)=x;
end
I know that there are probably many other mistakes in my script but could anybody help me with the error "Not enough input arguments"?
Not enough input arguments.
Error in fun_BSB (line 4)
y(j)=0.625*(c_CSB_KA(j)-c_AFS_KA(j)*i_CSB_oTS(j)*x(1)*(1-x(2))-c_CSB_KA(j)*x(3));
...some other errors...
Caused by:
Failure in initial objective function evaluation.
Optimization cannot continue.
Thank you for your help!
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!