MATLAB: Create a vector of vector exponents

exponentmatrix manipulation

Hi,
Assume I have a vector v and a square matrix A
v = [1, 2, 3, 4, 5];
A = randn(5);
I want to create a matrix
m = [v*A; v*A^2; v*A^3; ..; v*A^n]
Where n is a user input and ^ results in the matrix product operator (not dot product .^)
I can do that easily with a loop. Is there a quicker way of doing this without using a loop?

Best Answer

No, a for-loop is fastest, but you want to implement it the right way, with a recursive update,
m=repmat(v*A,n,1); %pre-allocate
for i=2:n
m(i,:) = m(i-1,:)*A;
end
That way, the process takes only n matrix multiplications.