I'm trying to write a for loop for the sum A+A^2+A^3+..+A^n.
Here is my code:
function [ x ] = Untitled2( A , n )
for k=1:n,
x =sum(A^k)
end
The problem I'm having with this is this function is listing the matrix A to each power without adding them. What can I do to add these together? Thank you in advance
while k<n+1 x=x+A^k end
– Jeremy Upsal Nov 04 '13 at 22:19end
– Heath Huffman Nov 04 '13 at 23:04