From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Array indexing anomaly
Date: Mon, 8 Mar 2010 16:36:20 +0000 (UTC)
Organization: Xoran Technologies
Lines: 17
Message-ID: <hn3924$ful$>
References: <hn192k$moc$> <hn1q1t$1v2$> <hn35c1$fb9$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1268066180 16341 (8 Mar 2010 16:36:20 GMT)
NNTP-Posting-Date: Mon, 8 Mar 2010 16:36:20 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: comp.soft-sys.matlab:614952

"David Young" <> wrote in message <hn35c1$fb9$>...

> I'd still like it if someone could say where the behaviour is properly documented, or where there's a previous discussion, and also whether it's a regretted design decision long in the past, or whether it's really worth having this complexity. After all, if you always work with, say, row vectors, then B would be a row vector too and the general rule (C same shape as B) would do what you want.

I can't find the documentation just now, but I'm starting to think the reasoning behind the design decision might be different from what I had said. 

The user population is accustomed to containing data in vectors, but now that I think about it, users are equally likely to prefer row vectors (for reasons I've already given examples for) as column vectors. Column vectors are what you tend to work with if, for example, your data vector x is the solution to a matrix vector equation A*x=b.

The problem now is that a very common operation you want to perform is indexing
using colon expressions  x(m:n:p). 

However, since (m:n:p) is always a row vector, then if the index vector always determined the shape of the output and if x was a column vector and if you wanted the output to be a column vector as well, you would have to do things 
like x((m:n:p)') in order to get the shape you wanted. This is obviously a fair addition in keystrokes and syntax complexity when you do a lot of colon-based indexing.

So the bottom line is, you pay in complexity no matter which design decision you make.