How can we do it bu function call?

3 次查看(过去 30 天)
Aimen Mujahid
Aimen Mujahid 2017-2-23
评论: Jan 2017-2-23
M=input('Enter number of manufacturers');
D=input('Enter number of distributers');
O=1;
T=1;
R=1;
Z=1;
Cmd=zeros(M:D);
for m=1:M;
for d=1:D;
Cmd(m,d)=input('Enter traveling cost for manufacturer to distributer');
disp(Cmd);
end
end
SumCmd=sum(Cmd(:));
disp(SumCmd);
  3 个评论
Aimen Mujahid
Aimen Mujahid 2017-2-23
编辑:Aimen Mujahid 2017-2-23
function for Cmd(m,d) number of M,D and cost of each element in tha matrix are inputs and Output should be the matrix of Cmd
Jan
Jan 2017-2-23
I assume you want Cmd=zeros(M, D) instead of Cmd=zeros(M:D).

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by