Home
Home
Apps
Apps
Ask
Ask
Manual
Manual
Share
Share

Error for one row submatrix


#1

Example: M=[1:3,4:6,7:9]

Then one can reduce M up to one column, e.g.

M(1..3,2..2)

But one cannot reduce M up to one row:

M(2..2,1..3)

produces an error (“M out of read bounds”). Selecting submatrices should be a symmetric operation, so in my opinion, this is a bug.

PS: Transponing to times is a workaround:
A=M'
A=A(1..3,2..2)
M=A'


#2

The a…b notation is a range, not an array of indices. Ranges are very useful, if somewhat strange animals. For one thing, they do not specify a step size, just a range of numbers. So in some sense they are sets.

They are not the equivalent of the a:b notation which specifies a sequence of numbers from a to b in increments of one. For indexing I recommend the a:b notation. So:


#3

I should add that you are right, from the examples in the docs it would seem it should work.


#4

Hello arsastronautica,

thank you for the explanation. I didn’t consider the a:b notation, but it’s surely the appropriate method.

Best regards
Robert