Appendix B
MATLAB Tutorial
This tutorial is an introduction to MATLAB. MATLAB is an interactive environment for scientific and engineering calculations, design, simulation and visualization. The aim of this tutorial is to enable students and control engineers to learn to use MATLAB in control engineering applications. The tutorial provides a brief introduction to the use of MATLAB with examples, and then describes the Control System Toolbox with examples. With the aid of this toolbox, for example, the control engineer can draw the Bode diagram, root locus or time response of a system in a few seconds and analyse and design a control system in a very short time.
B.1 MATLAB OPERATIONS
A variable in MATLAB can be a scalar, a complex number, a vector, or a matrix. A variable name can be up to 31 characters long and must start with a letter. It can contain letters, numbers, and underscore characters.
If a data entry, a statement, or any command is not terminated by a semicolon, the result of the statement is always displayed.
An integer number can be assigned to a variable name as follows:
>> w = 5; >> p = -3;
A real number is entered by specifying a decimal point, or the exponent:
>> q = 2.35; >> a = 5.2e-3;
When entering a complex number, the real part is entered first, followed by the imaginary part:
>> p = 2 + 4*i; >> q = 12*exp (i*2);
A row vector is entered by optionally separating the elements with commas. For example, the vector
p = [2 4 6]
is entered as
>> p = [2, 4, ...
Get Microcontroller Based Applied Digital Control now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.