# Matlab冒號符號

``1:10``

MATLAB執行語句並返回一個包含整數的行向量，從`1``10` -

``````ans =

1    2    3    4    5    6    7    8    9   10``````

``100: -5: 50``

MATLAB執行語句並返回以下結果 -

``````ans =
100    95    90    85    80    75    70    65    60    55    50``````

``0:pi/8:pi``

MATLAB執行語句並返回以下結果 -

``````ans =
Columns 1 through 7
0    0.3927    0.7854    1.1781    1.5708    1.9635    2.3562
Columns 8 through 9
2.7489    3.1416``````

`A(:,j)`

`A`的第`j`

`A(i,:)`

`A`的第`i`

`A(:,:)`

`A(j:k)`

`A(j)`, `A(j+1)`,`...`,`A(k)`

`A(:,j:k)`

`A(:,j)`, `A(:,j+1)`,`...`,`A(:,k)`

`A(:,:,k)`

`A(i,j,k,:)`

`A(:)`

`A`的所有要素，被視爲單列。在賦值語句的左側，`A(:)`填充`A`，從之前保留其形狀。在這種情況下，右側必須包含與`A`相同數量的元素。

## 示例

``````A = [1 2 3 4; 4 5 6 7; 7 8 9 10]
A(:,2)      % second column of A
A(:,2:3)    % second and third column of A
A(2:3,2:3)  % second and third rows and second and third columns``````

``````A =
1     2     3     4
4     5     6     7
7     8     9    10

ans =
2
5
8

ans =
2     3
5     6
8     9

ans =
5     6
8     9``````