function calling problem in my main
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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)
%This function calculates the distance between any two cartesian coordinates.
delta_x=goal(1)-start(1);
delta_y=goal(2)-start(2);
% Calculate the distance to the goal
dis=sqrt(delta_x^2+delta_y^2);
%dis=sqrt((x1-x2).^2 + (y1-y2).^2);
end
Consider Start=[1,1] and goal [10,10]
When I try to call fitness function at the following line in my code. it says to many input arguments.
[particle(i).Cost, particle(i).Sol]=fitness(particle(i).Position);
I dont know how to resolve it.
2 Kommentare
KSSV
am 9 Apr. 2019
Your function accepts x1,y1,x2,y2,start,goal........what does particle(i).Position output?
Antworten (0)
Siehe auch
Kategorien
Mehr zu Analog Input and Output finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!