blue_arkedia
blue_arkedia

Reputation: 471

How can I create a matrix using vector k=[8 9 6 5 4 3]

How can I create the following matrix?

[0 0 0 
8  0 0 
9  8 0 
6  9 8
5  6 9
4  5 6]

Upvotes: 1

Views: 133

Answers (1)

Jim Lewis
Jim Lewis

Reputation: 45105

How about the toeplitz function?

c=[0 8 9 6 5 4 3]
r=[0 0 0]
t=toeplitz(c,r)

(Disclaimer: untested!)

T should be:

0 0 0
8 0 0 
9 8 0 
6 9 8 
5 6 9 
4 5 6 
3 4 5

Upvotes: 1

Related Questions