Please enable JavaScript.
Coggle requires JavaScript to display documents.
ARRAY(LIST OF NUMBERS ARRANGED IN ROW AND/OR COLUMNS) - Coggle Diagram
ARRAY(LIST OF NUMBERS ARRANGED IN ROW AND/OR COLUMNS)
Vectors (One-dimensional)
A one-dimensional array is a list of numbers that is
placed in a row or a column
Create Vectors
Variable_name = [ type vectors elements]
Constant spacing specifying the first term, second term, and last term
In a vector with constant spacing the difference between the elements is the same. Ex: 2 4 6 8 10 (the different is 2)
A Vector in which the first term is m, the spacing is q, and the last term is n is creating by
variable_name = [ m:q:n ]
variable_name = m:q:n
Types of Vectors
Row Vector
Column Vector
Use : store information and data, in terms of table
Matrices (Two-dimensional)
Two-dimensional array
Has numbers in rows and columns
Store information like in a table
Important in linear algebra, use also in science and engineering to describe physical quantities
Creating Matrix
types of matrix
Square matrix (number in rows and columns are equal)
General matrix ( number in rows and columns are different)
Rows of a matrix can also be entered as vectors using the notation forcreating vectors with constant spacing, or the
linespace command
The zeros, ones, and eye commands
The zeros and the ones (m,n)
Create a matrix with m rows and n columns. Elements of the numbers 0, and 1 respectively
The eye (n)
Create a square matrix with n rows and n columns which is the diagonal elements are equal to 1 and rest is 0
Transpose Operator
Applied to a vector, switches a row (column) vector to a column (row) vectors
Applied to matrix, switch the rows (columns) to columns (rows)
Applied by typing a single qoute ' following the variable to be transposed
Array Addresing
Vectors
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
A single vector element, v(k), can be used just as a variable
It is possible to change the value of only one element of a vector by reassigning a new value to specific address. By typing : v(k) = value
A single element can also be used as a variable in a mathematical expression
Matrix
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 a element in row k and column p
Similar to vectors, it is possible to change the value of just one
element of a matrix by assigning a new value to that element.
Single elements can be used like variables in mathematical
expressions and functions
Using a Colon : In addressing arrays
For Vector
va(:) Refers to all the elements of the vector.
va(m:n) Refers to elements m through n of the vector
va.
For 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.
Adding elements to a matrix
Elements can be added to an existing vector by
assigning values to the new elements.
Elements can also be added to a vector by
appending existing vectors.
Rows and/or columns can be added to an existing matrix
by assigning values to the new rows or columns