for i=1:1:k %k = 100 people
for j=1:1:l %l = 5 orders
Resultx = a + b + d(j); % cost of drink Resultx
Resulty = f + g + c(j); % cost of food Resulty
end
Matrix(i) = [Resultsx1...j Resulty1...j]
end
这些% notes
是为了帮助我表达我想在脑海中解决的问题,然后在我的脚本中。
让我们声称我们希望每个i
人都将值存储在它订购的饮料和食物的成本矩阵中。
所以对于人来说i = 1
,
1[1 5] %people 1, first order: drink costs 1 and food costs 5
2[2 3] %people 1, second order: drink costs 2 and food costs 3
...
j[x y] %people 1, j order: drink and food costs x and y
!!! Matrix(1) = sort (j [x,y]) !!!
为人i = 2
,
1[1 5] %people 2, first order: drink costs 1 and food costs 5
2[2 3] %people 2, second order: drink costs 2 and food costs 3
...
j[x y] %people 2, j order: drink and food costs x and y
!!! Matrix(2) = sort (j [x,y]) !!!
为人i = k
,
1[1 5] %people k, first order: drink costs 1 and food costs 5
2[2 3] %people k, second order: drink costs 2 and food costs 3
...
j[x y] %people k, j order: drink and food costs x and y
!!! Matrix(i) = sort (j [x,y]) !!!
我想按升序将每次迭代i
的每个结果形成一个矩阵
Matrix(i) = sort (j [x,y]).
也许不是最好的范例,但提前谢谢你。