can not get the answer

1 次查看(过去 30 天)
sss dzu
sss dzu 2012-10-12
Could anyone help me with this problem? I can not get the same answer with the book. It should be =147.2551. This is I got so far
V=[3 7 4 5 2 6];
x=[1 7 8 17 22 27];
y=[28 18 16 2 10 8];
for i=1:30;
for j=1:30;
for k=1:6;
d(k)= sqrt((x(k)-i).^2+(y(k)-j).^2);
cost(k)=.5.*d(k).*V(k);
c(i,j)=sum(cost(k));
f=min(c(i,j));
end
end
end

采纳的回答

Azzi Abdelmalek
Azzi Abdelmalek 2012-10-12
编辑:Azzi Abdelmalek 2012-10-12
V=[3 7 4 5 2 6];
x=[1 7 8 17 22 27];
y=[28 18 16 2 10 8];
for i=1:30
for j=1:30
c(i,j)=0; % modification 1
for k=1:6
d(k)= sqrt((x(k)-i).^2+(y(k)-j).^2);
cost(k)=.5.*d(k).*V(k);
c(i,j)=c(i,j)+cost(k); %modification 2
end
end
end
f=min(c(:)) % modification 3
  6 个评论
Azzi Abdelmalek
Azzi Abdelmalek 2012-10-13
dzu format your code (look at Walter's link)

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Downloads 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by