how to write a very concise expression for matrix power
2 ビュー (過去 30 日間)
古いコメントを表示
I have a row vector, e.g. [1,2,3,4], and I want to put, say 3 different power [1;2;3] to create a matrix as follow:
[1,2,3,4]?^[1;2;3] = [1,2,3,4 ; 1,4,9,16 ; 1,8,27,64].
Anyone knows how to get it without using a loop. Many thanks!
0 件のコメント
採用された回答
Matt J
2016 年 10 月 12 日
As of R2016b, you can just do this
[1;2;3] .^ [1,2,3,4]
Otherwise, use bsxfun()
4 件のコメント
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!