function [O]=fitness(x1,y1,x2,y2,start,goal)
dis=distance(start,goal);
theta=pathsmoothness (x1,x2,y1,y2,goal);
z=dis+theta;
O=1/(z+0.001);
end
function theta= pathsmoothness (x1,x2,y1,y2,goal)
theta1 =atan((y2-y1)/(x2-x1));
theta2= atan(((goal(2))-(y1))/(goal(1)-(x2)));
theta= theta1-theta2;
end
function [dis] = distance(start,goal)
delta_x=goal(1)-start(1);
delta_y=goal(2)-start(2);
dis=sqrt(delta_x^2+delta_y^2);
end
Consider Start=[1,1] and goal [10,10]
[particle(i).Cost, particle(i).Sol]=fitness(particle(i).Position);
I dont know how to resolve it.
2 件のコメント
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/455251-function-calling-problem-in-my-main#comment_691675
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/455251-function-calling-problem-in-my-main#comment_691675
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/455251-function-calling-problem-in-my-main#comment_691690
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/455251-function-calling-problem-in-my-main#comment_691690
サインインしてコメントする。