Create a specific matrix (MATLAB)

Dear members
I want create a square matrix in such a way that I got the general form:
For example if we have m=4, we got:
How can I program that please!

 Accepted Answer

Try this —
M = hankel(1:4,4:-1:1)
M = 4×4
1 2 3 4 2 3 4 3 3 4 3 2 4 3 2 1
.

2 Comments

@Star Strider Thank you! That's what I need
As always, my pleasure!

Sign in to comment.

More Answers (1)

This is one way:
A = flipud(toeplitz([4 3 2 1]))
A = 4×4
1 2 3 4 2 3 4 3 3 4 3 2 4 3 2 1

Categories

Find more on MATLAB in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!