Re: Matrix indexing: bug or wanted?
- From: us <us@xxxxxxxxxxxxxxx>
- Date: Mon, 17 Jul 2006 11:56:58 -0400
RobR:
<SNIP matrix indexing conundrum...
matrixIndex =
4 4 4 4 4
5 5 5 5 5
Xindexed =
8 8 8 8 8
9 9 9 9 9
dont't you think, Xindexed should be more like
Xindexed =
8 16 24 32 40
9 18 27 36 45
no, the first result is exactly right: it has been correct for 20+
years and will stay for years to come... more important, however, it
is really what you would expect it to be
one of the solutions for your request
% assume your X
x=X;
% the engine
[xr,xc]=size(x);
[ixr,ixc]=meshgrid((0:xc-1).*xr,4:5);
r=x(ixr+ixc);
% the result
r
-and- look at
help sub2ind
for more options
us
.
- References:
- Matrix indexing: bug or wanted?
- From: RobR
- Matrix indexing: bug or wanted?
- Prev by Date: Re: colorbar overlapping plot label
- Next by Date: Re: Airy pattern, how to plot?
- Previous by thread: Re: Matrix indexing: bug or wanted?
- Next by thread: Re: Matrix indexing: bug or wanted?
- Index(es):