MATLAB: Construct Power of Matrix without for loop

MATLABpower of matrix

Hi, everyone:
Suppose I have a 2 by 2 matrix A, if I want construct a larger matrix B that is defined as:
B=[A, A^2, A^3, A^4, … A^N];
is it possible to do it without for loop?
Thanks

Best Answer

Example
A=magic(2);
N=3;
B=cell2mat(arrayfun(@(x) A^x,1:N,'un',0))