Vectorization of matrices power
显示 更早的评论
Hi all,
Let A a matrix n*n and let N an integer. I wish to create a matrix of power of the form AN = [I A A^2,...,A^N], where I=eye(n), without resorting to a "for" cycle. I have tried to take a look at several commands, including cumprod, kron, etc, and trying to combine them, but I failed. I made it only for the scalar case, i.e. n=1.
After that, I wish to create a matrix
AA = [I 0 0 0;A I 0 0;A^2 A I 0;A^3 A^2 A I]
without using any "for" cycle. I have noticed that the first column of AA is equal to AN' (if it may help). Any hints? Thanks.
1 个评论
Matt J
2013-11-12
It is doubtful that a for-loop is to be feared here. Surely you can't be doing this for N very large?
采纳的回答
更多回答(2 个)
Sean de Wolski
2013-11-12
This should give you the tools you need:
x = (1:3).^(1:3)
xm = tril(toeplitz(x))
Ubaldo Tiberi
2013-11-13
0 个投票
1 个评论
but just by combining elementary Matlab operations such as blkdiag, kron, cumprod
If A is symmetric you might be able to. But I think a for-loop will be the most efficient, regardless. Are you sure you need to build these matrices explicitly? They contain a lot of redundant data. What are you planning to use them for?
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!