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?
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.
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 + e−x)/2 | imag(x) |
Imaginary part |
sinh(x) |
(ex − e−x)/2 | conj(x) |
Complex conjugate |
tanh(x) |
(ex − e−x)/(ex + e−x) |
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 |
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: | v: ∇ | x: x‐mark | b: blue | c: cyan(sky blue) |
‐. dash‐dot | d: ⋄ | <: < | s: □ | k: black |
3.135.191.86