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
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