how to write a very concise expression for matrix power
Show older comments
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!
Accepted Answer
More Answers (1)
dpb
on 12 Oct 2016
>> bsxfun(@power,[1:4],[1:3].')
ans =
1 2 3 4
1 4 9 16
1 8 27 64
>>
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!