

6.3 Assignment Solutions  Lecture 6
Solution mfiles:
6.3.1 Part A
The key to this exercise is relating the unit weight of a battery to the amount of power it supplies, which is proportional to the travel time and thus distance travelled.
We begin by creating a new mfile, and we include
exercise_batterypower on the first line.
Next, we define the range of weights for the batteries as
[1:3000]:
m_{new batteries} = [1:3000]


Figure 6.34 Click image to enlarge, or click here to open


A unit battery is of weight 1kg. We can easily compute the amount of Energy in a unit battery by dividing the total Energy in a 9kg battery (from exercise 1) by the weight of the battery (9):
E_{unit batteries} = E_{batteries total} / m_{batteries}


Figure 6.35 Click image to enlarge, or click here to open


We can now compute the amount of energy for the range of battery weights by multiplying the range vector by the unit battery weight:
E_{new batteries} = m_{new batteries} * E_{unit batteries}


Figure 6.36 Click image to enlarge, or click here to open


The total weight for the Segway is the range of battery weights added to the bare weight of the Segway:
m_{segway} = m_{segway nobat} + m_{new batteries}


Figure 6.37 Click image to enlarge, or click here to open


At this point, we will reevaluate equations
, , and , which we have used in exercise_batterypower.m. We merely need to copy and paste them into this mfile.


Figure 6.38 Click image to enlarge, or click here to open


Using equation
we can now compute the total time travelled for the Energy in the range of battery weights
t_{travelled} = E_{new batteries} / P_{from batteries}


Figure 6.39 Click image to enlarge, or click here to open


We now convert the range of
t_{travelled} to distance travelled in km:
dist_{travelled} = t_{travelled} * v_{kmh2msec}(v_{const})
dist_{travelled km} = dist_{travelled} / 1000


Figure 6.40 Click image to enlarge, or click here to open


Finally, we plot the result vector
dist_{travelled km} over the range of battery weights m_{new batteries}:
plot(m_{new batteries}, dist_{travelled km}), xlabel('Weight of Batteries in kg'), ylabel('Distance travelled in km'), title('Weight of batteries vs. distance travelled at constant velocity of 20km/h'), grid


Figure 6.41 Click image to enlarge, or click here to open


The graph suggests that for an equal amount of additional battery power, the additional distance travelled decreases over time.


Figure 6.42 Click image to enlarge, or click here to open


6.3.2 Part B
In this part of the assignment, we are expanding on what has been computed in Part A, by adding another dimension of variability.
We begin by creating a new mfile, and we include
exercise_batterypower on the first line.


Figure 6.43 Click image to enlarge, or click here to open


Next, we define the range of weights for the batteries and velocities:
m_{new batteries} = [1:20:3000]
v_{var} = [1:2:100]


Figure 6.44 Click image to enlarge, or click here to open


Next, we again define a unit battery of 1kg:
E_{unit batteries} = E_{batteries total} / m_{batteries}


Figure 6.45 Click image to enlarge, or click here to open


We initialize the result matrix
dist_{travelled km} to an empty matrix:
dist_{travelled km} = [ ]


Figure 6.46 Click image to enlarge, or click here to open


Similar to
exercise_mesh, we place the computation for one of the ranges, v_{var}, in a for loop:
for v=1:length(v_{var})
end


Figure 6.47 Click image to enlarge, or click here to open


We first compute the total weight of the Segway and range of battery weights.
m_{segway} = m_{segway nobat} + m_{new batteries}


Figure 6.48 Click image to enlarge, or click here to open


At this point, we will reevaluate equations 5.3, 5.4, and 5.5, which we have used in exercise 1. We merely need to copy and paste them into this mfile.


Figure 6.49 Click image to enlarge, or click here to open


Using equation
we can now compute the total time travelled for the Energy in the range of battery weights
t_{travelled} = E_{new batteries} / P_{from batteries}


Figure 6.50 Click image to enlarge, or click here to open


We now convert the range of
t_{travelled} to distance travelled in km and store the resulting vector in the matrix.
dist_{travelled} = t_{travelled} * v_{kmh2msec}(v_{const})
dist_{travelled km}(v,:) = dist_{travelled} / 1000


Figure 6.51 Click image to enlarge, or click here to open


Finally, we plot the resulting matrix
dist_{travelled km} over the range of battery weights m_{new batteries} and velocities v_{var}:
mesh(m_{new batteries}, v_{var}, dist_{travelled km}), xlabel('Weight of batteries in kg'), ylabel('Velocity in km/h'), zlabel('Distance travelled in km');


Figure 6.52 Click image to enlarge, or click here to open


The resulting graph suggests that with increasing weight of the batteries, the marginal additional distance travelled decreases. This suggests that there is some value (given the problem setup) for which battery weight is most efficient.


Figure 6.53 Click image to enlarge, or click here to open


On the other hand, the graph also suggests that the lower the velocity at which the Segway travels, the higher the possible total distance travelled. This makes sense, as the lower the velocity, the lower the force required to move the vehicle.


Figure 6.54 Click image to enlarge, or click here to open



