1. Distinguish elementwise calculations from matrix multiplication
Starting conditions
Create and as column vectors.
Procedure
Calculate segment lengths using sqrt and .^, and compare with hypot.
Compare the sizes and meanings of dx.*dy and dx*dy'.
Results to retain
The difference between the two distance calculations and a comparison of multiplication methods.
Items to record and points to check
Operations
Result size
Units/meaning
Points to check
Did you keep power and matrix multiplication operators distinct?
Did you distinguish units of length from units of squared length?
2. Calculate vertical velocity using timestamp intervals
Starting conditions
s, height=[0,.4,.9,.7] m.
Procedure
Compute diff(height) and diff(t), then divide elementwise to calculate average vertical velocity for the three intervals.
Plot height at measurement times and vertical velocity at the midpoint of each interval. Label axes and units on each plot.
For the final interval – s, calculate values using the actual time difference and assuming 1 s. In two rows, record the height change, time difference used, and calculated vertical velocity, and explain the difference.
Results to retain
Height/vertical velocity plots and a comparison for the final interval.
Items to record and points to check
Interval [s]
Height change [m]
Velocity [m/s]
Points to check
Did you account for diff returning one fewer element than the original array?
Did you use the irregular measurement intervals as given?
3. Reuse a calculation rule as a function
Starting conditions
Apply segmentLength=@(dx,dy) hypot(dx,dy) to new coordinate changes as well.
Procedure
Pass two vectors of equal length to the function.
Check the resulting size when one input is a row vector and the other is a column vector.
Check that inputs have the same shape, or standardize their shapes.
Results to retain
A small reusable function and 1 invalid input example.
Items to record and points to check
Input size
Output size
Processing rule
Points to check
Did implicit expansion produce a larger matrix than expected?
Did fixing the shape preserve element correspondence?