MATLAB Vectors and Sensor Data

English translation

Combine time, height, and battery records into an array, then select and inspect the intervals and conditions you need.

Before practice

01 Does the third row record time 3 seconds?

Description

MATLAB's first row has index 1, and the first time in these data is 0 seconds. The third row is at 2 seconds.

02 If no values satisfy the condition, can you write 0?

Description

Distinguish an empty result from an actual measurement of 0.

Execution conditions

Use MATLAB or MATLAB Online. The basic activities run in MATLAB alone and do not require a drone connection.

Practice

Preview practice mlx scriptDownload practice mlx script

1. Convert a measurement table to an array

Starting conditions

Use the example's time, height, and battery columns.

Procedure

  1. Create three column vectors and combine them into a 5×3 array.
  2. Use size to check the dimensions, and extract the third row and the height column separately.

Results to retain

Items to record and points to check
Selection method
Array size
Meaning of values

Points to check

  • Did you place the three values at each time in the same row?
  • Have you distinguished index 3 from time 3 seconds?

2. Select by height condition and time interval

Starting conditions

Select height≥.5 m and 1≤t≤3 seconds separately.

Procedure

  1. Create two logical arrays and check which rows are selected.
  2. Select records that satisfy both conditions, and record time, height, and battery together.
  3. Change the height condition to .8 m and check which rows are excluded.

Results to retain

Items to record and points to check
Condition
Selected times [s]
Height [m]
Battery [%]

Points to check

  • Have you avoided incorrectly mixing separate height and time criteria?
  • Are column meanings preserved when conditions change?

3. Handle empty selection results

Starting conditions

No records satisfy height≥2 m.

Procedure

  1. Select rows with height at least 22 m, and record the results of size and isempty. If no heights are selected, branch to display 'No results' instead of the maximum.
  2. Before running the selection code, append one value to each column vector t, height_m, and battery_pct, then rerun measurements=[t,height_m,battery_pct]. The new elements of all three vectors must form the same measurement row. Set the added row's height to at least 22 m and record the three values.
  3. Rerun the same selection code and record the selected row count, displayed result, and maximum selected height before and after the addition, side by side.

Results to retain

Items to record and points to check
Condition
Number of rows
Subsequent calculation/display

Points to check

  • Have you avoided replacing an empty array with an actual height of 0?
  • Can the added row be included without manually changing the number 5 in the code?

Official examples and data