Question: KIn this activity you will learn how to define matrices, use the size ( ) command to find the size % of a matrix,

KIn this activity you will learn how to define matrices, use the size() command to find the size \%of a matrix, generate an identity matrix, and also compute the transpose of a matrix using \%the "." operator.
WMatrices in Matlab can be constructed by entering each row of values.
KRows are separated from each other using a semicolon.
\%For example, consider the \(2\times 4\) matrix B defined as:
\[
B=\left[\begin{array}{lllllllll}
1 & 2 & 3 & 4 ; & 5 & 6 & 7 & 8
\end{array}\right]
\]
\%The size() function can be used to compute the number of rows and columns of a matrix. compute the number of rows and columns of B by using the size() function and store these values. [numRowsTest, numColsTest]= size(B)
\%The eye() function can be used to create an n by n identity matrix.
\%create the \(3\times 3\) identity matrix and store it as I.
\[
I=\operatorname{eye}(3)
\]
\%The "dot-tic" operator can be used to transpose a matrix.
\%Take the transpose of the matrix B and store it as the matrix C.
\[
C=B .^{\prime}
\]
Script (
\%Define the \(3\times 3\) matrix A with all 1's in the first row, all 2's in the second row, \%and all 3's in the 3rd row.
Zuse the size() function to compute the number of rows and columns of matrix A.\%store these quantities as variables numRows and numCols.
\%use the eye() function to create the \(4\times 4\) identity matrix. Store this matrix as I.
Kcompute the transpose of the matrix A. Store this transposed matrix as the matrix D. Assessment:
Matrix A is correct
numRows variable value is correct
numCols variable value is correct
Identity matrix is correct
Matrix D is correct
KIn this activity you will learn how to define

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!