'I have a task for a Matlab assignment and don't know how to solve it
In this exercise we will practice loops. Create a new vector (size 1x3 or 3x1) storing the diagonal using a for loop (and potentially conditions) to iterate over the elements of the initial matrix and keep just the ones in the diagonal. Hint: Notice that the elements in the diagonal has the same number for row and column.
The initial matrix is r1 =
80 75 59
13 59 58
83 31 21
The diagonal is [80 59 21].
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
