octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Indexing on row matrices


From: Daniel J Sebald
Subject: Indexing on row matrices
Date: Mon, 12 Aug 2013 02:32:05 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16

In working with assert.m and converting column vector indexed matrices/vectors to strings I'm wondering if the following is correct:

a = [11 22]
a =

   11   22

a ([1 2])
ans =

   11   22

a ([1; 2])
ans =

   11   22

I can easily work around this with

a ([1; 2]) (:)
ans =

   11
   22

but before doing so, I notice that the documentation isn't quite clear on what the outcome should be:

"
8.1 Index Expressions
=====================

   Vectors are indexed using a single index expression.  Matrices (2-D)
and higher multi-dimensional arrays are indexed using either one index
or N indices where N is the dimension of the array.  When using a
single index expression to index 2-D or higher data the elements of the
array are taken in column-first order (like Fortran).

   The output from indexing assumes the dimensions of the index
expression.  For example:

     a(2)       # result is a scalar
     a(1:2)     # result is a row vector
     a([1; 2])  # result is a column vector
"

Now, the last result might lead one to believe that the above result for a row vector is not correct. However, the discussion clearly has drifted to the topic of matrices so the documentation neither confirms or contradicts the output for indexing a row vector. If the result above is correct, then it might be good to add that to the 8.1 documentation.

Dan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]