How to create a symmetrical matrix out of a column?

后端 未结 3 1314
南笙
南笙 2021-01-28 16:19

For example, I want to turn the following column:

[90; 175; 600; 650; 655; 660] 

into the matrix:

[ 90, 175, 600, 650, 655, 66         


        
3条回答
  •  感情败类
    2021-01-28 16:41

    The built-in function toeplitz gives what you want after a couple of flips:

    >> col = [90; 175; 600; 650; 655; 660];
    >> result = flipud(toeplitz(flip(col)))
    result =
        90   175   600   650   655   660
       175   600   650   655   660   655
       600   650   655   660   655   650
       650   655   660   655   650   600
       655   660   655   650   600   175
       660   655   650   600   175    90
    

提交回复
热议问题