Consider the following arrays defined in MatLab's workspace: \begin{equation*} W = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 2 & 3 & 0 & 0 \\ 4 & 5 & 6 & 0 \\ 7 & 8 & 9 & 1 \end{bmatrix} \qquad Z = \begin{bmatrix} 2 & 9 & 0 \\ 7 & 5 & 6 \end{bmatrix} \end{equation*} Retrieve the following sub-matrices from W and Z in a single line of MATLAB code: Retrieve or create from W the following sub-arrays: $\begin{bmatrix} 2\\7\\9 \end{bmatrix}$ $\begin{bmatrix} 0 & 0 & 0 & 0 & 0 & 0 \end{bmatrix}$ $\begin{bmatrix} 1 & 1 \end{bmatrix}$ Retrieve or create from Z the following sub-arrays: $\begin{bmatrix} 6 & 0 & 5 & 9 & 7 & 2 \end{bmatrix}$ $\begin{bmatrix} 6 & 5 & 7 \\ 2 & 9 & 0 \end{bmatrix}$ Retrieve or create from W and Z the following sub-arrays: $\begin{bmatrix} 9 & 0 & 2 & 3 \\ 5 & 6 & 4 & 5 \end{bmatrix}$
Added by Gema T.
Close
Step 1
To retrieve the sub-array [2 7 0], we can use the following code: W([3 17 7]) To retrieve the sub-array [0 0 0 0], we can use the following code: W(8:11) To retrieve the sub-array 0, we can use the following code: W(12) To retrieve the sub-array [1 1], we can Show more…
Show all steps
Your feedback will help us improve your experience
Neel Patel and 72 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
MatLab: Let z = magic(5). a. Perform the following operations on z in the given order: i. Divide column 2 by 3. ii. Add the elements of the third row to the elements in the fifth row (the third row remains unchanged). iii. Multiply the elements of the first column by the corresponding elements of the fourth column and place the result in the first column. iv. Set the diagonal elements to 2.
Sri K.
[10 points] Create the following two row vectors: d=[6 -1 4 0 -2 5], and e=[7 5 9 0 1 3]. (a) Use the two vectors in a MATLAB command to create a matrix such that the first row consists of elements 1 through 3 of vector d, the second row consists of elements 2 through 4 of vector e, and the third row consists of elements 3 through 5 of vector d. (b) Use the two vectors in a MATLAB command to create a matrix such that the first column consists of elements 1 through 4 of vector d, and the second column consists of elements 2 through 5 of vector e.
(a) Create the following matrix and put the answer in p4a. Do not input element by element.
Supreeta N.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD