Customer Service Analytics - Make Sense of All Your Data.pptx
Matrix operations in MATLAB
1. PRACTICAL
Name- Saloni Singhal
M.Sc. (Statistics) II-Sem.
Roll No: 2046398
Course- MATH-409L
Numerical Analysis Lab
Submitted To: Dr. S.C. Pandey
1
2. OBJECTIVE
1. A review of basic MATLAB functions on command
window: Scalar addition, subtraction, Matrix operations,
elementary row transformations
Pre-Requisites
• Creating row and column vector
• Basic matrix operation: MATLAB allows to process all of the values in a matrix
using a single arithmetic operator or function.
Ex. matrix multiplication computes the inner products between rows and columns, using
the (*) operator
• percent (%) symbol used to add comments ( to describe the code) to MATLAB codes
which don’t appear in output. 2
3. Theory
MATLAB (matrix laboratory) is designed to operate primarily on whole matrices and arrays.
ln MATLAB variables are multidimensional arrays, irrespective of the type of data. A matrix
is a two-dimensional array i.e. an m × n array of scalars from a given field F, primarily used
in linear algebra. The individual values in the matrix are called entries.
Command Window -used to enter commands at the command line, which is indicated by the
prompt (>>).
Workspace - We can explore data create or import from files. It specifies the name, values,
size and storage class of the variables.
• When output variable is not specified, MATLAB uses the variable ans, to store the results
• Semicolon suppresses the display of output in the Command Window
• format command: used to display required decimal digits (short, long)
3
4. Commands Used
4
• Concatenation: joining arrays to make it augmented.
[] (square brackets) are the concatenation operator.
• Using a single subscript to refer to a particular element in an array
is called linear indexing
• To refer to multiple elements, colon operator(:) is used by
specifying a range
• Rand() generates uniformly distributed random number in the
interval (0,1). Random matrix can be generated by specifying
dimensions.
• Dot (.) and the operator(*,/,+,^) form one symbol for element-by-
element wise operations. Matrix dimensions should be same.
7. Conclusion
For matrix multiplication, the number of columns in the first matrix must
be equal to the number of rows in the second matrix. The result matrix has
the number of rows of the first and the number of columns of the second
matrix.
Below error is shown if this is violated:
7
The only documented features in MATLAB with
colored text are error (red), warning (orange),
and by adding a hyperlink (blue), comment
(green), string (purple)