MATLAB: Construction of shifted matrix from known matrix

fir filterimpulse response

I have matrix 'h' which is of matrix 2056. I need to build matrix 'H' using shifted version of 'h'.
Construction example : Suppose an impulse responce has length of 6 :
h = [h0 h1 h2 h3 h4 h5 h6] '
I need to change length to FIR filter length of 4 such as :
H = [ h0 0 0 0 ]
[ h1 h0 0 0 ]
[ h2 h1 h0 0 ]
[ h3 h2 h1 h0 ]
[ h4 h3 h2 h1 ]
[ h5 h4 h3 h2 ]
[ 0 h5 h4 h3 ]
[ 0 0 h5 h4 ]
[ 0 0 0 h5 ]
I need to produce this kind of matrix. Any help will be very useful. Thank you

Best Answer

Try toeplitz()
h = 1:6;
m = 4;
n = numel(h)+m-1;
M = toeplitz([h zeros(1,m-1)], [h(1) zeros(1,m-1)])
Result
>> M
M =
1 0 0 0
2 1 0 0
3 2 1 0
4 3 2 1
5 4 3 2
6 5 4 3
0 6 5 4
0 0 6 5
0 0 0 6