For loop in function

1 vue (au cours des 30 derniers jours)
Judith Lange
Judith Lange le 30 Mai 2018
Modifié(e) : Judith Lange le 1 Juin 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!

Réponse acceptée

Walter Roberson
Walter Roberson le 30 Mai 2018
  1 commentaire
Judith Lange
Judith Lange le 1 Juin 2018
Modifié(e) : Judith Lange le 1 Juin 2018
Thank you very much. This link really helped me and even I understood it. Now I am going to fix the other problems :D

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with Optimization Toolbox dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by