help-octave
[Top][All Lists]
Advanced

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

Re: size and display of N-d matrices (octave-3.4.2)


From: Przemek Klosowski
Subject: Re: size and display of N-d matrices (octave-3.4.2)
Date: Wed, 10 Aug 2011 17:16:25 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc15 Lightning/1.0b2 Thunderbird/3.1.10

On 08/10/2011 03:26 PM, Sergei Steshenko wrote:

octave:1>  a(1,1,1,1) = 1
octave:2>  a(1,1,1,2) = 2
a =

ans(:,:,1,1) =  1
ans(:,:,1,2) =  2

octave:5>  b(1,1,1,1) = 3
octave:6>  b(2,1,1,1) = 4
b =

    3
    4

1) why does 'octave' treat 'a' and 'b' differently ?
2) why 'b' is shown to have just two dimensions ?
3) why colons when 'a' is displayed ?

1) the issue of style

In the old days, the saying went: 'Punctuality is the courtesy of the kings'. Nowadays, careful editing of correspondence seems to have become the courtesy of the kings. It is hard to follow a letter that has lots of boilerplate quoted or cut-and-paste material, with interesting, relevant content hidden at the end. In extreme, it makes a mockery of the common recommendation for bottom-posting --- if the quoted material is dumped indiscriminately in front of the new content, it would actually be less hard to read if it was top-posted, especially on the mobile devices that more of us use nowadays. In other words, literate persons are expected to weave the trimmed quotes and their responses into a coherent message --- that's the true meaning of "bottom-posting".

The point here is that careful editing makes huge difference to the reader. Sure, it takes time and effort --- as Seneca said, "I apologize for this very long letter but I was out of time" --- but the goal of writing is to communicate, so if it is worth doing at all, it is worth doing well.

Thank you for the opportunity to get it off my chest. I thought it would not be impolite to send it to the list even though most postings here are usefully edited.


2) the issue of your questions

a)
Matlab basic data type started as a 2-D array, with vestiges of 1-D linear, column-wise data layout visible behind the curtains. It was then extended to multiple dimensions, by allowing more than two indices _added_after_ the initial ones. 2-D data is still treated specially, in that multidimensional arrays with singular trailing n-2 indices are displayed as if those indices didn't exist. Similarly, if you set e(2,1)=3 you can call it back as e(2,1) or e(2). Note that you can even use e(2,1,1) or e(2,1,1,1,1,1,1), but of course not e(2,1,2).

b)
In the absence of non-trivial 3rd and higher dimensions, the matrices are shown as if they were 2-D (see the above explanation)

c)
Colons are a shorthand for the entire range of the index in the respective position, so in my example, e(2,:) results in '3', and e(:,1) results in the vector [0 3]'.






n order to check out code snippets, one has to cut and paste


reply via email to

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