


































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An introduction to matlab, a powerful numerical computing environment and high-level programming language. Learn about its capabilities, applications, and features such as matrix and vector-based methods, mathematical functions, and integration with other languages. Discover how to use matlab for mathematics, computation, algorithm development, data acquisition, modeling, simulation, data analysis, and scientific graphics.
Typology: Slides
1 / 42
This page cannot be seen from the preview
Don't miss anything!



































MATLAB system:
Integrative Development Environment (IDE) MATLAB Mathematical Function Library
A = [16 3 2 13; 5 10 11 8; 9 6 7 12; 4 15 14 1]
A = 16 3 2 13 5 10 11 8 9 6 7 12 4 15 14 1
The transpose operation is denoted by an apostrophe or single quote, '. It flips a matrix about its main diagonal and it turns a row vector into a column vector.
So
A'
produces
ans = 16 5 9 4 3 10 6 15 2 11 7 14 13 8 12 1
If you try to use the value of an element outside of the matrix, it is an error: t = A(4,5) Index exceeds matrix dimensions.
On the other hand, if you store a value in an element outside of the matrix, the size increases to accommodate the newcomer: X = A; X(4,5) = 17 X = 16 3 2 13 0 5 10 11 8 0 9 6 7 12 0 4 15 14 1 17
The colon, :, is one of the most important MATLAB operators.
It occurs in several different forms. The expression 1:
is a row vector containing the integers from 1 to 10:
1 2 3 4 5 6 7 8 9 10
To obtain non-unit spacing, specify an increment. For example,
100:-7:
is
100 93 86 79 72 65 58 51
and
0:pi/4:pi
is
0 0.7854 1.5708 2.3562 3.
MATLAB does not require any type declarations or dimension statements. When MATLAB encounters a new variable name, it automatically creates the variable and allocates the appropriate amount of storage. If the variable already exists, MATLAB changes its contents and, if necessary, allocates new storage. For example, num_students = 25
creates a 1-by-1 matrix named num_students and stores the value 25 in its single element. To view the matrix assigned to any variable, simply enter the variable name.
Variable names consist of a letter, followed by any number of letters, digits, or underscores. MATLAB is case sensitive; it distinguishes between uppercase and lowercase letters A and a are not the same variable.
MATLAB uses conventional decimal notation, with an optional decimal point and leading plus or minus sign, for numbers. Scientific notation uses the letter e to specify a power-of-ten scale factor. Imaginary numbers use either i or j as a suffix. Some examples of legal numbers are 3 -99 0. 9.6397238 1.60210e-20 6.02252e 1i -3.14159j 3e5i
All numbers are stored internally using the long format specified by the IEEE floating-point standard. Floating-point numbers have a finite precision of roughly 16 significant decimal digits and a finite range of roughly 10-308^ to 10+308.
MATLAB provides a large number of standard elementary mathematical functions, including abs, sqrt, exp, and sin. Taking the square root or logarithm of a negative number is not an error; the appropriate complex result is produced automatically. MATLAB also provides many more advanced mathematical functions, including Bessel and gamma functions. Most of these functions accept complex arguments. For a list of the elementary mathematical functions, type
help elfun
For a list of more advanced mathematical and matrix functions, type
help specfun
help elmat
Some of the functions, like sqrt and sin, are built in.
Built-in functions are part of the MATLAB core so they are very efficient, but the computational details are not readily accessible. Other functions, like gamma and sinh, are implemented in M-files.
Here are a few examples, and the resulting values: rho = (1+sqrt(5))/ rho =
a = abs(3+4i) a = 5 z = sqrt(besselk(4/3,rho-i)) z = 0.3730+ 0.3214i huge = exp(log(realmax)) huge = 1.7977e+ toobig = pi*huge toobig = Inf docsity.com