## 2.14.1 Indexing in matrices

Indexing in matrices can be done by giving the indices of selected rows and columns or by boolean indices or by using the `\$` symbol.
```
-->A=[1 2 3;4 5 6]
A  =

!   1.    2.    3. !
!   4.    5.    6. !

-->A(1,2)
ans  =

2.

-->A([1 1],2)
ans  =

!   2. !
!   2. !

-->A(:,1)
ans  =

!   1. !
!   4. !

-->A(:,3:-1:1)
ans  =

!   3.    2.    1. !
!   6.    5.    4. !

-->A(1)
ans  =

1.

-->A(6)
ans  =

6.

-->A(:)
ans  =

!   1. !
!   4. !
!   2. !
!   5. !
!   3. !
!   6. !

-->A([%t %f %f %t])
ans  =

!   1. !
!   5. !

-->A([%t %f],[2 3])
ans  =

!   2.    3. !

-->A(1:2,\$-1)
ans  =

!   2. !
!   5. !

-->A(\$:-1:1,2)
ans  =

!   5. !
!   2. !

-->A(\$)
ans  =

6.

-->//

-->x='test'
x  =

test

-->x([1 1;1 1;1 1])
ans  =

!test  test  !
!            !
!test  test  !
!            !
!test  test  !

-->//

-->B=[1/%s,(%s+1)/(%s-1)]
B  =

!   1     1 + s  !
!   -     -----  !
!   s   - 1 + s  !

-->B(1,1)
ans  =

1
-
s

-->B(1,\$)
ans  =

1 + s
-----
- 1 + s

-->B(2) // the numerator
ans  =

!   1     1 + s  !

-->//

-->A=[1 2 3;4 5 6]
A  =

!   1.    2.    3. !
!   4.    5.    6. !

-->A(1,2)=10
A  =

!   1.    10.    3. !
!   4.    5.     6. !

-->A([1 1],2)=[-1;-2]
A  =

!   1.  - 2.    3. !
!   4.    5.    6. !

-->A(:,1)=[8;5]
A  =

!   8.  - 2.    3. !
!   5.    5.    6. !

-->A(1,3:-1:1)=[77 44 99]
A  =

!   99.    44.    77. !
!   5.     5.     6.  !

-->A(1,:)=10
A  =

!   10.    10.    10. !
!   5.     5.     6.  !

-->A(1)=%s
A  =

!   s     10     10  !
!                    !
!   5     5      6   !

-->A(6)=%s+1
A  =

!   s     10     10     !
!                       !
!   5     5      1 + s  !

-->A(:)=1:6
A  =

!   1.    3.    5. !
!   2.    4.    6. !

-->A([%t %f],1)=33
A  =

!   33.    3.    5. !
!   2.     4.    6. !

-->A(1:2,\$-1)=[2;4]
A  =

!   33.    2.    5. !
!   2.     4.    6. !

-->A(\$:-1:1,1)=[8;7]
A  =

!   7.    2.    5. !
!   8.    4.    6. !

-->A(\$)=123
A  =

!   7.    2.    5.   !
!   8.    4.    123. !

-->//

-->x='test'
x  =

test

-->x([4 5])=['4','5']
x  =

!test        4  5  !
```