
228 Accelerating MATLAB
®
Performance
Note the use of the reserved keyword end in these examples. MATLAB automatically
converts end to the size of the corresponding dimension (in our example, the value 5). We
can even use this value to compute index values relative to the dynamic run-time end of
the array. For example, we can shift the array elements to the right using the following
code (note the corresponding built-in MATLAB function circshift):
>> x([end 1:end-1])
ans =
15 11 12 13 14
>> circshift(x,[0,1]); % equivalent to above
In this example, e n d-1 translated into 4, so the indexing variant was essentially x([5
1:4]), that is, the ...