To create matrix a
with the given values, we can write:
main.m20 chars2 lines
To swap the first row with the second row, we can use the following code:
main.m27 chars2 lines
The a([1 2], :)
represents the first and second rows of matrix a
. Similarly, a([2 1], :)
represents the second and first rows of matrix a
. By swapping these rows, we effectively swap the first row with the second in the matrix.
gistlibby LogSnag