The special end operator is an easy shorthand way to refer to the last element of v: v(end) % Extract the last element Swap the two halves of v to make a new vector: v2 = v() % Extract and swap the halves of v
The colon notation in MATLAB provides an easy way to extract a range of elements from v: v(3:7) % Extract the third through the seventh elements Or the subscript can itself be another vector: v() % Extract the first, fifth, and sixth elements The subscript can be a single value: v(3) % Extract the third element Let's start with the simple case of a vector and a single subscript.