MATLAB: MxM correlation Matrix output

covarianceoutputvariance matrix

Given a vector
Vec = [ 0 1 2 3 4 5 6 7 8 9 ]
I want to use the vec value to obtain a matrix output as
0 1 2 3 4 5 6 7 8 9
1 0 1 2 3 4 5 6 7 8
2 1 0 1 2 3 4 5 6 7
3 2 1 0 1 2 3 4 5 6
mat = 4 3 2 1 0 1 2 3 4 5
5 4 3 2 1 0 1 2 3 4
6 5 4 3 2 1 0 1 2 3
7 6 5 4 3 2 1 0 1 2
8 7 6 5 4 3 2 1 0 1
9 8 7 6 5 4 3 2 1 0
Your input is highly appreciated. Thanks in advance

Best Answer

toeplitz(vec)