| | | 7 8 Single-Colon Indexing with Different Array Types When you index into a standard MATLAB array using a single colon, MATLAB returns a column vector (see variable n, below). When you index into a structure or cell array using a single colon, you get a comma-separated list "Comma-Separated Lists" on page 3-83 (see variables c and s,below). Create three types of arrays: n= [12 3; 4 5 6]; c = {1 2; 3 4}; s = cell2struct(c, {'a', 'b'}, 1); s(:,2)=s(:,1); Use single-colon indexing on each: | | |
| | | Indexing on Assignment When assigning values from one matrix to another matrix, you can use any of the styles of indexing covered in this section. Matrix assignment statements also have the following requirement. In the assignment A(J,K,...) = B(M,N,...), subscripts J, K, M, N,etc. may be scalar, vector, or array, provided that all of the following are true: • The number of subscripts specified for B, not including trailing subscripts equal to 1, does not exceed ndims(B). • The number of nonscalar subscripts specified for A equals the number of nonscalar subscripts specified for B.For example, A(5,1:4,1,2) | | |