MATLAB: How does the syntax (:) work?

Posted by user198729 on Stack Overflow See other posts from Stack Overflow or by user198729
Published on 2010-04-25T05:12:36Z Indexed on 2010/04/26 19:03 UTC
Read the original article Hit count: 213

Filed under:
|
|

Given the following example:

>> I=[2 1 3;3 2 4]

I =

     2     1     3
     3     2     4

>> I(:)

ans =

     2
     3
     1
     2
     3
     4

>> I(1:2)

ans =

     2     3

Why does I(:) return a column vector while I(1:2) returns a shorter row vector?

© Stack Overflow or respective owner

Related posts about matlab

Related posts about syntax