Here is the assignment i need help with. i have attached the assignment and the main code and function file are below.

thanks

MAIN CODE

clear all

clc

min_d=fminsearch(@distance, [0,30]);

v=[3,7,4,5,2,6];

for i=1:6

if i==1;

c1=.5 * min_d * v(i);

end

if i==2;

c2=.5 * min_d * v(i);

end

if i==3;

c3=.5 * min_d * v(i);

end

if i==4;

c4=.5 * min_d * v(i);

end

if i==5;

c5=.5 * min_d * v(i);

end

if i==6;

c6=.5 * min_d * v(i);

end

end

min_c=c1+c2+c3+c4+c5+c6;

fprintf('the minimum cost is 2.1%',min_c)


FUNCTION FILE

function d= distance(x2,y2)

x1=[1,7,8,17,22,27];

y1=[28,18,16,2,10,8];

d=sqrt((x2-x1)^2+(y2-y1)^2);

end

this is for matlab by the way

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.