From: James on
Hi All,
I am trying to generate a matrix that looks like this:

0 1 2 3 4 5
1 0 1 2 3 4
2 1 0 1 2 3
3 2 1 0 1 2
4 3 2 1 0 1
5 4 3 2 1 0

Can anyone think of a way to generate this matrix without a For loop? Thanks!
From: us on
"James " <jjaques(a)lgsinnovations.com> wrote in message <i3clg9$dau$1(a)fred.mathworks.com>...
> Hi All,
> I am trying to generate a matrix that looks like this:
>
> 0 1 2 3 4 5
> 1 0 1 2 3 4
> 2 1 0 1 2 3
> 3 2 1 0 1 2
> 4 3 2 1 0 1
> 5 4 3 2 1 0
>
> Can anyone think of a way to generate this matrix without a For loop? Thanks!

do NOT double post(!)...
a solution was given here, already...

http://www.mathworks.com/matlabcentral/newsreader/view_thread/288548#768598

us
From: James on
us <us(a)neurol.unizh.ch> wrote in message <14d4e8e6-f21f-41ff-9ea6-dd1d7db40509(a)i24g2000yqa.googlegroups.com>...
> On Aug 4, 11:15 pm, "James " <jjaq...(a)lgsinnovations.com> wrote:
> > Hi All,
> > I am trying to generate a matrix that looks like this:
> >
> > 0 1 2 3 4 5
> > 1 0 1 2 3 4
> > 2 1 0 1 2 3
> > 3 2 1 0 1 2
> > 4 3 2 1 0 1
> > 5 4 3 2 1 0
> >
> > Can anyone think of a way to generate this matrix without a For loop? Thanks!
>
> one of the many solutions
>
> r=toeplitz(0:5)
> %{
> % r =
> 0 1 2 3 4 5
> 1 0 1 2 3 4
> 2 1 0 1 2 3
> 3 2 1 0 1 2
> 4 3 2 1 0 1
> 5 4 3 2 1 0
> %}
>
> us

That will do it. Thanks!
From: James on
"us " <us(a)neurol.unizh.ch> wrote in message <i3cm30$ji0$1(a)fred.mathworks.com>...
> "James " <jjaques(a)lgsinnovations.com> wrote in message <i3clg9$dau$1(a)fred.mathworks.com>...
> > Hi All,
> > I am trying to generate a matrix that looks like this:
> >
> > 0 1 2 3 4 5
> > 1 0 1 2 3 4
> > 2 1 0 1 2 3
> > 3 2 1 0 1 2
> > 4 3 2 1 0 1
> > 5 4 3 2 1 0
> >
> > Can anyone think of a way to generate this matrix without a For loop? Thanks!
>
> do NOT double post(!)...
> a solution was given here, already...
>
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/288548#768598
>
> us

Was not intentional. Not even sure how it happened. But thanks for the reply on the other post.