For loop in function
2 views (last 30 days)
Show older comments
Judith Lange
on 30 May 2018
Edited: Judith Lange
on 1 Jun 2018
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 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Get Started with Optimization Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!