Q: Can the ':'-character be used for indexing?
"The colon is one of the most useful operators in MATLAB."
-- Matlab reference
»A(:,j) %is the j-th column of ASurprisingly, the character ':' works just the same!
»A(':',j) %is the j-th column of AThis feature comes handy if you use dynamic indexing:
»X=1:5; idx=3; disp(X(idx)); idx=2:4; disp(X(idx)); idx=':'; %looks better than idx=1:length(X)! disp(X(idx)); 3 2 3 4 1 2 3 4 5And how about this?
X=rand(5,5,5); idx={2,':',3}; X(idx{:}) % same as X(2,:,3)!Too bad 'end' does not work the same way...