MATLAB: Creating a special matrix

create a matrix

Hello all,
I want to create this matrix
A=[0 0 1 1 1;0 1 1 1 0;1 1 1 0 0]
How can I get ?
Thank you.

Best Answer

One way:
v = [0 0 1 1 1 ];
A = [v; circshift(v,[0 -1]); circshift(v,[0 -2])]