11.0: MATLAB/Simulink Installation

Mechatronics: Fundamentals, Design, Integration, and Validation · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    From LibreTexts, under CC BY-NC 4.0, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    11.0: MATLAB/Simulink Installation
    Lab B.0 Objectives

    After completing this lab section, you will be able to:

    1. Program and run MATLAB software in the MATLAB environment.
    2. Program and run Simulink graphic-based software in the MATLAB/Simulink environment.

    MATLAB Installation

    Install MATLAB R2019a (or 2024b) on your own laptop and update your academic license. Get the campus software by the link below.

    https://www.mathworks.com/academia/t...igibility.html

    During the installation, you will need to select the following MathWorks toolboxes. They will be used to program the mini-Segway projects or other projects.

    1. MATLAB and Simulink
    2. Real-Time Workshop\(\mathrm{ ^{TM}}\)
    3. Control System Toolbox\(\mathrm{ ^{TM}}\)
    4. Curve Fitting Toolbox\(\mathrm{ ^{TM}}\)
    5. DSP System Toolbox\(\mathrm{ ^{TM}}\)
    6. Image Processing Toolbox\(\mathrm{ ^{TM}}\)
    7. Instrument Control Toolbox\(\mathrm{ ^{TM}}\)
    8. Optimization Toolbox\(\mathrm{ ^{TM}}\)
    9. Signal Processing Toolbox\(\mathrm{ ^{TM}}\)
    10. Simscape\(\mathrm{ ^{TM}}\)
    11. Simscape Multibody\(\mathrm{ ^{TM}}\)
    12. Stateflow
    13. Symbolic Math Toolbox\(\mathrm{ ^{TM}}\)

    Most US college students have a free MATLAB license. Any issues associated with your license can be addressed by your IT department.

    If you already have MATLAB R2019a (or 2024b) installed, check if you have the required products by typing the command ver and press “Enter” (or “return”) in the MATLAB command window.

    Simulation with MATLAB 

    Before conducting a simulation study, we need to introduce MATLAB fundamentals. There are two ways to run a program in MATLAB. You can choose either of them for your future lab operations. The final results will be the same. The two programing methods are shown from Steps 1 to 5 below.

    1. Start MATLAB 2019a (or 2024b) from either the Windows Start Menu or the desktop. A MATLAB command window will pop up (as shown in Figure B.1). The basic configuration of the command window should include “Tool bar,” “Current Folder Browser,” “Command Window,” and “Workspace.”
    A screenshot of MATLAB window including file, command, and workspace sections.
    Figure B.1: MATLAB command window.
    1. In the command window, type the first command in this lab section. Type the command display (‘Hello, Spartan!’) at the “\(\mathrm{>}\)\(\mathrm{>}\)” prompt and press “Enter” (or “return”) on the keyboard. The result is shown in Figure B.2.
    A screenshot of MATLAB command window showing a command, disp('Hello, Spartan!') and the associated display of "Hello, Spartan!".
    Figure B.2: First command ‘Hello, Spartan.’
    1. Script is also used widely in MATLAB. Left single click on the “New” icon and select “script.” Then a new “Editor” window will pop up (see Figure B.3). Type the disp command in the file named “Test_1.m”. Note that commands disp and display are equivalent.
    A screenshot of MATLAB script editor window with code,  disp('Hello Spartan!), in the first line.
    Figure B.3: Script editor window.
    1. Single click the “Run” button in the tool menu. The “Save” window will pop up. Then type “Test_1” into the File name and click “Save.” The file name and results will appear in the command window (see Figure B.4 below) accordingly.
    A screenshot of MATLAB file-save window showing the process of saving to Test_1.m file (MATLAB Code file).
    Figure B.4: File save window.

    Type Test_1 in the MATLAB command window, and Hello Spartan! will be displayed, as shown in Figure B.5.

    A screenshot of MATLAB command window showing the result of running "Test_1.m" file in the command window displaying "Hello Spartan!".
    Figure B.5: Results in the Command window.
    1. A variable can be defined with an assigned value using the expression, \(\boldsymbol{\mathrm{<}}\)variable name\(\boldsymbol{\mathrm{>}}\) = \(\boldsymbol{\mathrm{<}}\)expression\(\boldsymbol{\mathrm{>}}\);, where the semicolon is used if you do not want to show the result in the MATLAB command window. Note that both a string and numerical value can be assigned to a variable. Now, try to delete the semicolon in your second command. Your assignment result should appear in the MATLAB command window. Try the command in Figure B.6. to become familiar with the variable assignment.
    A screenshot of MATLAB command window showing the result of revisiting “Hello Spartan!” using variable assignment method.
    Figure B.6: Revisit “Hello Spartan!” with variable assignment.

    This page titled 11.0: MATLAB/Simulink Installation was last modified on Thu, 23 Jul 2026 04:44:02 GMT and is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Guoming Zhu (Co-DREAM OER) .