Laboratory Report 2M
Laboratory Report 2M
2
Introduction to MATLAB
I. Objectives.
a) To encode matrices into MATLAB.
b) To perform matrix operation such as addition, subtraction, multiplication
and division.
c) To access and alter specific elements of a matrix by referring to their
row and column indices.
II. Introduction. (Research your own introduction)
III. Procedures.
1.) Matrices in MATLAB
a.) Creating Matrices in MATLAB
In creating matrices, you can directly specify the elements within square brackets
([]). Elements are separated by spaces or commas within a row, and rows are
separated by semicolons (;).
Example:
Input:
Output:
• Identity Matrix
An identity matrix is a square matrix with ones on the diagonal and zeros
elsewhere.
• Modifying a column:
A(:, n) = [n];
Example:
A(:, 3) = [14; 15; 16]; % Modify the entire 3rd column
or
Matrix B =
5 7 9 11 13
6 8 10 12 14
18 14 1 5 22
16 18 20 22 24
26 27 28 31 33