如何在MATLAB中基于矢量创建三角形矩阵? [英] How can I create a triangular matrix based on a vector, in MATLAB?
本文介绍了如何在MATLAB中基于矢量创建三角形矩阵?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一个像这样的向量:
Let's say I've got a vector like this one:
A = [101:105]
实际上是:
[ 101, 102, 103, 104, 105 ]
我只想使用向量/矩阵函数和运算符来生成矩阵:
And I'd like to use only vector/matrix functions and operators to produces the matrix:
101 102 103 104 105
102 103 104 105 0
103 104 105 0 0
104 105 0 0 0
105 0 0 0 0
或以下矩阵:
101 102 103 104 105
0 101 102 103 104
0 0 101 102 103
0 0 0 101 102
0 0 0 0 101
有任何想法吗?
(我是MATLAB的新手,但是我对此感到很头疼...)
(I'm very much a novice in MATLAB, but I've been saddled this stuff...)
推荐答案
hankel(A)
将为您提供第一个矩阵
hankel(A)
will get you the first matrix
triu(toeplitz(A))
将带给您第二个.
-洛伦(Loren)
这篇关于如何在MATLAB中基于矢量创建三角形矩阵?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文