How to create matrix 10x10 with same diagonal vector and empry value

I am new to matlab and i need to create a 10x10 matrix, which consists of same number by diagonal, triangular matrix and empty values (like on image)

 Accepted Answer

M = toeplitz([2,1,zeros(1,8)])
M = 10×10
2 1 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 0 0 0 0 1 2

More Answers (0)

Categories

Find more on Partial Differential Equation Toolbox in Help Center and File Exchange

Asked:

on 28 Nov 2020

Commented:

on 7 Dec 2020

Community Treasure Hunt

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

Start Hunting!