Genetic Algorithm, argument should be real?
이전 댓글 표시
Hi all.. I want to ask about my objective function :
function f = function1(x)
p=(atand((x(4))/(x(5)-100)));
g=(((x(5)-100)^2+x(4)^2)^0.5);
s=((x(1)^2+g^2-x(2)^2)/(2*x(1)*g));
t=((x(2)^2+g^2-x(1)^2)/(2*x(2)*g));
alpha=((acosd(s))+p);
betha=((acosd(t))-p);
f=((x(2)*sind(alpha+betha))/(2*x(3)*cosd(betha)));
after execution with genetic algorithm solver the result are :
??? Error using ==> sind at 16 Argument should be real.
Error in ==> fungsi1 at 8 f=((x(2)*sind(alpha+betha))/(2*x(3)*cosd(betha))); Error in ==> validate>@(x)fitness(x,FitnessFcnArgs{:}) at 135 fitness = @(x) fitness(x,FitnessFcnArgs{:});
Error in ==> fcnvectorizer at 23 y = fun(pop);
Error in ==> makeState at 48 Score = fcnvectorizer(state.Population(initScoreProvided+1:end,:),FitnessFcn,1,options.SerialUserFcn);
Error in ==> gaunc at 41 state = makeState(GenomeLength,FitnessFcn,Iterate,output.problemtype,options);
Error in ==> ga at 279 [x,fval,exitFlag,output,population,scores] = gaunc(FitnessFcn,nvars, ...
sind not real argument? why? because value of p not real?
[EDITED, Jan, code formatted]
댓글 수: 1
Jan
2012년 10월 1일
Please learn how to format your code. It is easy and has been explained repeatedly. Thanks.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!