compute from a set of parameters
이전 댓글 표시
C = 60; % capacity of a truck
demand = [30 35 24 15 14 48]; % goods to deliver
m = 2; % no of avaible trucks
i wanted to compute how many trucks needed to deliver the goods
and also the number of trips taken by each truck
we will take demand of each person, and check if the sum of demand is greater than the capacity of the truck,
eg: 30 + 35 > 60, in our example, yes - so cant load both to one truck
if it is greater than the capacity we can check if any other demand can fit into the truck, else we need to load the demand into a new truck
how can i compute the number of trucks used and the number of trips
from the above example, output will be
number_of_trucks_used = 2
number_of_trips = [2 1];
i.e. first truck 2 trips and second truck 1 trip
i also wanted to store the goods loaded into the truck in a cell array, and the position taken from vector demand in another cell array like
cell_array_value = { [30 15 14] [48] ; [35 24] }
cell_array_pos = { [1 4 5] [6] ; [2 3] }
please can some one help me to solve it in a simple way
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!