Graphics Reference
In-Depth Information
Here are some examples:
>> x =(1:10)
x =
1 2 3 4 5 6 7 8 9 10
>> x (6)
Ans =
6
We have obtained the sixth element of the vector x.
>> x(4:7)
Ans =
4 5 6 7
We have obtained the elements of the vector x located between the fourth and the seventh, both inclusive.
>> x(2:3:9)
Ans =
2-5-8
We have obtained the elements of the vector x located between the second and ninth, both inclusive, but
separated by three units. Note the 9 does not conform the the rule and so is not included in the answer.
>> x(9:-3:2)
Ans =
9 6 3
We have obtained the elements of the vector x located between the ninth and second, both inclusive, but
separated in three units and starting at the ninth.
A.13 Matrix Variables
MATLAB defines arrays by inserting brackets around all its row vectors separated by a comma. Vectors can be entered
by separating its components by whitespace or comma, as we already know. For example, a dimension 3 x 3 matrix
variable can be entered in the following two ways:
M = [a 11 a 12 a 13 ; a 21 a 22 a 23 ; a 31 a 32 a 33 ]
M = [a 11 , a 12 , a 13 ; a 21 , a 22 , a 23 ; a 31 , a 32 , a 33 ]
 
Search WWH ::




Custom Search