[英]matrix based on vector and diagonal elements=1 using matlab
How can I create the following matrix 如何创建以下矩阵
1 0 0 0 0
k1 1 0 0 0
k2 k1 1 0 0
k3 k2 k1 1 0
k4 k3 k2 k1 1
Eg 例如
vector = [1 2 3 4 5]; %# replace this with values for [1 k1 k2 k3 k4]
out = toeplitz(vector,[1 0 0 0 0])
out =
1 0 0 0 0
2 1 0 0 0
3 2 1 0 0
4 3 2 1 0
5 4 3 2 1
EDIT 编辑
my vector is [k1 k2 k3 k4 k5], how can i apply tril or toeplitz?
我的矢量是[k1 k2 k3 k4 k5],我怎么能应用tril或toeplitz?
Using @gnovice's more convenient formulation, you use 使用@ gnovice更方便的配方,您可以使用
yourVector = [k1 k2 k3 k4 k5];
tril(toeplitz([1 yourVector(1:4)]))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.