For loop in function
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Judith Lange
il 30 Mag 2018
Modificato: Judith Lange
il 1 Giu 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 Commenti
Risposta accettata
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Get Started with Optimization Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!