2. Essential Knowledge
• for survival and growth in the present competitive and technological driven economy, It is
widely recognized that essential knowledgeable skills are
o Reading
o Writing
o Problem solving
**These are the basic communication, organization, and technical–logical-- mathematical skills required in the modern
workplace and for further growth these you get primarily school
• However, The marketable skills in addition to the preceding essentials are
o Information processing
o Management and administration
** These are majorly personal build ups and of cause you pay heavily t get certificate for them but level of competency is
based o performance records
• It is widely recognized and accepted by educators, labor experts, economists, and
educational leaders that in the coming decades, the biggest employment gains will be in
occupations that rely on
o Unique or specialized skills
o Intelligence
o Imagination
o Creativity
** These depends on your ability to spot what your environment needs and capitalize on it
Adopted from : Practical MATLAB® Basics for Engineers
4. 1.0 Creating Array (Vectors)
- An array is a list of numbers arranged in rows and/or columns. The simplest array (one-dimensional)
is a row or a column of numbers. A more complex array (two dimensional) is a collection of numbers
arranged in rows and columns
- A one-dimensional array is a list of numbers arranged in a row or a column, Any list of numbers can be
set up as a vector.
- Row vector: To create a row vector type the elements with a space or a comma between the elements
inside the square brackets.
- Column vector: To create a column vector type the left square bracket [ and then enter the elements with
a semicolon between them, or press the Enter key after each element.
- In MATLAB, a vector is created by assigning the elements of the vector to a variable This can be done in
several ways depending on the source of the information that is used for the elements of the vector
- Vectors can be created froma knownlist of numbers, by typing the elements (numbers) inside square
brackets [ ] i.e
- Creating vectors with constant spacingby specifyingthe firstterm,the spacing,and the last termi.e.;
- Creating Vectors with linear(equal) spacingby specifyingthe firstand lastterms,and the numberof
termsi.e.
5. 1.0 Creating Array (Two Dimensional Array)
- Two dimensional array ( also called a matrix) , has numbers in rows and columns
- A matrix is created by assigning the elements of the matrix to a variable. This is done by typing the
elements, row by row, inside square brackets [ ]
- First type the left bracket [ then type the first row, separating the elements with spaces or commas.
To type the next row type a semicolon or press Enter. Type the right bracket ] at the end of the last
row. i.e.
- The elements that are entered can be numbers or mathematical expressions that may include
numbers, predefined variables, and functions. Alltherowsmusthavethesamenumberof elements.
If an element is zero, it has to be entered as such
-
6. 1.0 Creating Array (Special Operations)
- The transpose operator, when applied to a vector, switches a row (column) vector to a column
(row) vector. When applied to a matrix, it switches the rows (columns) to columns (rows). The
transpose operator is applied by typing a single quote ’ i.e.
- The zeros(m,n),ones(m,n), and eye(n)commands can be used to create matrices that have
elements with special values
- The zeros(m,n) and the ones(m,n) commands create a matrix with m rows and n columns in which all
elements are the numbers 0 and 1, respectively
- The eye(n) creates a square matrix with n rows and n columns in which the diagonal elements are equal
to 1 and the rest of the elements are 0. This matrix is called the identity matrix.
7. 1.0 Creating Array (Array Addressing)
- Elements in an array (either vector or matrix) can be addressed individually or in subgroups . This is useful
when there is a need to redefine only some of the elements, when specific elements are to be used in
calculations, or when a subgroup of the elements is used to define a new variable.
- The address of an element in a vector is its position in the row (or column) For a vector named ve, ve(k)refers
to the element in position k. i.e
- The address of an element in a matrix is its position, defined by the row number and the column number
where it is located. For a matrix assigned to a variable ma, ma(k,p) refers to the element in row k and column
p. i.e
8. 1.0 Creating Array (Array Addressing)
- For a vector A colon can be used to address a range of elements in a vector or a matrix.
- va(:) Refers to all the elements of the vector va (either a row or a column vector).
- va(m:n) Refers to elements m through n of the vector va.
- For a matrix.
- A(:,n) Refers to the elements in all the rows of column n of the matrix A.
- A(n,:) Refers to the elements in all the columns of row n of the matrix A.
- A(:,m:n) Refers to the elements in all the rows between columns m and n of the matrix A.
- A(m:n,:) Refers to the elements in all the columns between rows m and n of the matrix A.
- A(m:n,p:q) Refers to the elements in rows m through n and columns p through q of the matrix A.
9.
10. 1.0 Creating Array (Array Addressing)
- A variable that exists as a vector, or a matrix, can be changed by adding elements to it (remember that a
scalar is a vector with one element). A vector (a matrix with a single row or column)
- Elements can be added to an existing vector by assigning values to the new elements. For example, if a vector
has 4 elements, the vector can be made longer by assigning values to elements 5, 6, and so on
- Rows and/or columns can be added to an existing matrix by assigning values to the new rows or columns.
This can be done by assigning new values, or by appending existing variables.
- If a matrix has a size of , and a new value is assigned to an element with an address beyond the size of the
matrix, MATLAB increases the size of the matrix to include the new element. Zeros are assigned to the other
elements that are added
- An element, or a range of elements, of an existing variable can be deleted by reassigning nothing to these
elements. This is done by using square brackets with nothing typed in between them
15. 1.0 Creating Array (Array Addressing)
- A variable that exists as a vector, or a matrix, can be changed by adding elements to it (remember that a
scalar is a vector with one element). A vector (a matrix with a single row or column)
- Elements can be added to an existing vector by assigning values to the new elements. For example, if a vector
has 4 elements, the vector can be made longer by assigning values to elements 5, 6, and so on
- Rows and/or columns can be added to an existing matrix by assigning values to the new rows or columns.
This can be done by assigning new values, or by appending existing variables.
- If a matrix has a size of , and a new value is assigned to an element with an address beyond the size of the
matrix, MATLAB increases the size of the matrix to include the new element. Zeros are assigned to the other
elements that are added
- An element, or a range of elements, of an existing variable can be deleted by reassigning nothing to these
elements. This is done by using square brackets with nothing typed in between them
16. 2.0 Mathematical Operations With Array
• Mathematical Operations on array are majorly on two forms; The one that follows the rule of linear algebra
and the element by element operations.
• The basic operators are the represented by the following symbols multiplication(*) , addition (+) ,
subtraction(-), division(/) and power (^)
• The operators are used directly for the case of linear algebra and for the element by element multiplication a
period is typed in front of the operators ( .*, ./, and .^ are used the addition and multiplication remaining the
same).
• The operations + (addition) and – (subtraction) can beused to add (subtract) arrays of identical size (the
same numbers of rows and columns) and to add (subtract) a scalar to an array. When two arrays are involved
the sum, or the difference, of the arrays is obtained by adding, or subtracting, their corresponding elements
• When a scalar (number) is added to (or subtracted from) an array, the scalar is added to (or subtracted
from) all the elements of the array.
•
17. 2.0 Mathematical Operations With Array
• Array Multiplication
The multiplication operation * is executed by MATLAB according to the rules of linear algebra. This means
that if A and B are two matrices, the operation A* B can be carried out only if the number of columns in
matrix A is equal to the number of rows in matrix B. The result is a matrix that has the same number of rows
as A and the same number of columns as B.
Two vectors can be multiplied only if they have the same number ofelements, and one is a row vector and the
other is a column vector . The multiplication of a row vector by a column vector gives a matrix, which is a
scalar (1 x 1 Matrix).
When an array is multiplied by a number (actually a number is a array), element in the array is multiplied
by the number.
The product of the multiplication of two square matrices (they must be ofthe same size) is a square matrix of
the same size. However, the multiplication of matrices is not commutative. This means that if A and Bare both
n x n , then A*B ≠B*A
For more understanding a review of Matrix Operations is advised .
18. 2.0 Mathematical Operations With Array
• ArrayDivision
• The division operation is also associated with the rules of linear algebra. The division operation can be
explained with the help of the identity matrix and the inverse operation.
• The identity matrix is a square matrix in which the diagonal elements are 1s, and the rest of the elements are
0s
• When the identity matrix multiplies another matrix (or vector), that matrix (or vector) is unchanged (the
multiplication has to be done according to the rules of linear algebra). Thisis equivalent to multiplying a
scalar by 1
• The matrix B is the inverse of the matrix A if, when the two matrices are multiplied, the product is the identity
matrix. Both matrices must be square and the multiplication order can be BA or AB
• Obviously B is the inverse of A, and A is the inverse of B. In MATLAB the inverse of a matrix can be obtained
either by raising A to the power of –1, , or with the inv (A) function
19. 2.0 Mathematical Operations With Array
• ArrayDivision
• MATLAB has two types of array division, right division (/) and left division ().
• Left division is used to solve the matrix equation
• So the solution of the above equation is In MATLAB the last equation can be written by using the
left division character:
• The right division solves the equation In MATLAB the last equation can be written using the
right division character
• The three methods (right, left and inv function) would be used to solve the equation
21. 2.0 Mathematical Operations With Array
• Element-by-element operations
• These operations are carried out on each ofthe elements of the array (or arrays).
• Element-by-element operations can be done only with arrays of the same size.
• Element-by-element multiplication, division, or exponentiation of two vectors or matrices is entered in
MATLAB by typing a period in front of the arithmetic operator.
• Element-by-element calculations are very useful for calculating the value of a function at many values of its
argument
• for the function y = x2 + 4x ,. Element-by-element operation is needed when x is squared. Each element in
the vector y is the value of y that is obtained when the value of the corresponding element of the vector x is
substituted in the equation. This is shown below.
• More Examples are also attached