Course materials · Robot Basic Lab

Getting Started with MATLAB and Live Scripts

English translation

Run commands and inspect variables, then create a Live Script that records input conditions alongside results.

Before practice

01 Does adding a semicolon also remove the variable?

Description

Only the displayed output is suppressed. Variables remain in the Workspace.

02 Will running only some sections always give the same results?

Description

Previously defined variables' current values can affect the result, so rerun from the inputs to check.

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. Check inputs and units first

Starting conditions

Start with distance .5 m and speed .25 m/s.

Procedure

  1. Create distance_m=0.5 and speed_mps=0.25, then calculate travel time using time_s=distance_m/speed_mps. Record the name, value, and size of the three Workspace variables.
  2. Run the time calculation line with and without a trailing semicolon. State whether the calculated value or the displayed output changes.

Results to retain

Items to record and points to check
Distance [m]
Speed [m/s]
Time [s]

Points to check

  • Did you store speed and time in separate variables?
  • Did you compare calculated values without changing units?

2. Combine into a script and change conditions

Starting conditions

Change the distance from .5 to .8 m and keep the speed at .25 m/s.

Procedure

  1. Organize inputs, calculations, and result explanations into separate sections.
  2. Change only the distance, rerun, and compare the times for the two conditions.
  3. Run only the calculation section without defining inputs, and check which variables it depends on.

Results to retain

Items to record and points to check
Condition
Distance [m]
Speed [m/s]
Calculated time [s]

Points to check

  • Did you save input definitions as well as outputs?
  • Do the modified conditions and latest output refer to the same experiment?

3. Use error messages to locate fixes

Starting conditions

Examine the cases of mistyping speed_mps as speed_ms and setting speed_mps=0.

Procedure

  1. Check the typo and division by 0 separately.
  2. Check that speed_mps>0 before calculating travel time.
  3. Run the file from the beginning and check that inputs, checks, and calculations all execute.

Results to retain

Items to record and points to check
Input issue
Observed behavior
Modified location

Points to check

  • Have you distinguished typos from physically invalid values?
  • Does it run without previous Workspace values?

Official examples and data