12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

[a a(a)]ans =1 2 3 1 4 74 5 6 2 5 87 8 9 3 6 9The colon symbol can be used as a single index to a matrix. Continuingthe previous example, if you typea(:)matlab interprets this as the columns <strong>of</strong> the a-matrix successivelystrung out in a single long column:>> a(:)ans =1472583693.5 End as a subscriptTo access the last element <strong>of</strong> a matrix along a given dimension, use endas a subscript (matlab version 5 or later). This allows you to go to thefinal element without knowing in advance how big the matrix is. Forexample:>> q = 4:10q =4 5 6 7 8 9 10>> q(end)ans =10>> q(end-4:end)ans =6 7 8 9 10>> q(end-2:end)ans =8 9 10This technique works for two-dimensional matrices as well:c○ 2000 by CRC Press LLC

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!