Text-only
Table of Contents (
frame
/
no frame
)
(9) Array Subscripting and Indexing
More Array Subscripting and Indexing in MATLAB
Array indices must be integers and can refer to:
A single element
A continuous range of elements
Use colon operator min:step:max
A randomly assorted list of elements
Try:
>> first_mat
>> A([ 1 7 2; 3 6 2])
ans = 4.000 1.200 8.000
7.2 10.0000 8.000
>> A(1:5,5)
>> A(:,5)
>> A(21:25)
>> A(1:end,end)
>> A(:,end)
>>A(21:end)'
>> A(4:5,2:3)
>>A([9 14; 10 15])
>>B= find(A>5)
>> C=size(A)
Useful Subscripting commands:
find
- returns index/subscript values for elements that satify a given condition
ind2sub
- converts element-wise index values to row-column subscript values
sub2ind
- converts row-column subscript values to element-wise index values
size
- returns the numbers of rows and columns in the matrix
Array_Subscripting_and_Indexing.src last modified Feb 11, 2014
Introduction
Table of Contents
(
frame
/
no frame
)
Printable
(single file)
© Dartmouth College