how to write a very concise expression for matrix power
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Matt J
il 12 Ott 2016
As of R2016b, you can just do this
[1;2;3] .^ [1,2,3,4]
Otherwise, use bsxfun()
4 Commenti
Più risposte (1)
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!