A. The example below shows how to:
1. Define a vector with incrementing integers.
2. Define a second vector (subvector) which is formed from partial elements of the first vector.
>> a = 1:10
a =
1 2 3 4 5 6 7 8 9 10
>> b = a(5:7)
b =
5 6 7
B. The example below shows how to get a submatrix from an existing matrix:
c =
1 2 3
4 5 6
7 8 9
>> d = c(2:3,2:3)
d =
5 6
8 9
C. Divide all elements of a vector by an integer:
>> e = a/2
e =
0.5000 1.0000 1.5000 2.0000 2.5000 3.0000 3.5000 4.0000 4.5000 5.0000
沒有留言:
張貼留言