Appendix I
MATLAB® Introduction

A MATLAB icon. On a Windows‐based computer with MATLAB® software installed, you can double‐click on the MATLAB icon (like the one on the right side) to start MATLAB. Once MATLAB has been started, you will see the MATLAB desktop as shown in Figure I.1, which has the MATLAB Command window in the lower middle where a blinking cursor appears to the right of the MATLAB prompt ‘>>’ waiting for you to type in MATLAB commands/statements. It also contains other windows each labeled Current Folder, Editor, and Workspace (showing the contents of MATLAB memory).

How do we work with the MATLAB Command window?

  • By clicking on ‘New’/‘Open’ in the groups of functionalities under HOME tab and then selecting an item in their dropdown menus, you can create/edit any file with the MATLAB editor.
  • By typing any MATLAB commands/statements in the MATLAB Command Window, you can use various powerful mathematic/graphic functions of MATLAB.
  • If you have an M‐file which contains a series of commands/statements for performing a target procedure, you can type in the filename (without the extension ‘.m’) to run it.
  • By clicking on ‘Set Path’ in the right part of the toolstrip, you can make the MATLAB search path list include or exclude the paths containing the files you want to or not to be run.
  • By typing a search term like a keyword or a function name into the Search Documentation box at the top‐right part, you can search help documentation for what you want to know about.
  • To undock, i.e. separate the Editor Window from the MATLAB desktop, click on the Editor Actions button (down‐arrow‐shaped) in the top‐right part of the Editor Window and select ‘Undock’ in its drop‐down menu. To dock the Editor Window back to the desktop, click on the Editor Actions button and select ‘Dock Editor’ in its drop‐down menu.

Some of mathematical functions and special reserved constants/variables defined in MATLAB are listed in Table I.1. Table I.2 shows the graphic line specifications used in the plot( ) command.

Image described by caption and surrounding text.

Figure I.1 The MATLAB desktop with Command/Editor/Current folder/Workspace windows.

Table I.1 Functions and variables in MATLAB.

Function Remark Function Remark
cos(x) exp(x) Exponential function
sin(x) log(x) Natural logarithm
tan(x) log10(x) Common logarithm
acos(x) cos−1(x) abs(x) Absolute value
asin(x) sin−1(x) angle(x) Phase of a complex number [rad]
atan(x) π/2≤tan−1(x)≤π/2 sqrt(x) Square root
atan2(y,x) π ≤ tan−1(y/x) ≤ π real(x) Real part
cosh(x) (ex + ex)/2 imag(x) Imaginary part
sinh(x) (exex)/2 conj(x) Complex conjugate
tanh(x) (exex)/(ex + ex) round(x) The nearest integer (round‐off)
acosh(x) cos h−1(x) fix(x) The nearest integer towards 0
asinh(x) sin h−1(x) floor(x) The greatest integer ≤ x
atanh(x) tan h−1(x) ceil(x) The smallest integer ≥ x
max Maximum and its index sign(x) 1(positive)/0/−1(negative)
min Minimum and its index mod(y,x) Remainder of y/x
sum Sum rem(y,x) Remainder of y/x
prod Product eval(f) Evaluate an expression
norm Norm feval(f,a) Function evaluation
sort Sort in the ascending order polyval Value of a polynomial function
clock Present time poly Polynomial with given roots
find Index of element(s) roots Roots of polynomial
tic Start a stopwatch timer toc Read the stopwatch timer (elapsed time from tic)
date Present date
Reserved variables with special meaning
i, j images pi π
eps Machine epsilon Inf, inf Largest number(∞)
realmax,realmin Largest/smallest positive number NaN Not_a_Number(undetermined)
end The end of for loop or if, while break Exit while/for loop
nargin Number of input arguments nargout Number of output arguments
varargin Variable input argument list varargout Variable output argument list

Table I.2 Graphic line specifications used in the plot( ) command.

Line type Point type (Marker symbol) Color
‐ solid line .(dot) +(plus) *(asterisk) r: red m: magenta
: dotted line ^: Δ >: > o(circle) g: green y: yellow
‐‐ dashed line p: A four-point star. v: ∇ x: x‐mark b: blue c: cyan(sky blue)
‐. dash‐dot d: ⋄ <: < s: □ k: black
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.191.86