0
votes

Lets say I have a 3x3 matrix and a 3x1 vector, I want to multiply my matrix A with vector P multiple times.

A=[0 0.3 0.5; 0.8 0 0.5; 0.2 0.7 0] * P=[1; 1; 1] 

I want to multiply the answer of this with P for N times.

Now I can do this by hand but I am being forced to use Matlab and it is giving me a headache.

Cheers

1
So you mean (((A*P)*P)*P)....)*P ? Use a for loop - Dan
A*P is a 3x1 vector, how do you want to matrix-multiply that with another 3x1 vector? - Amro
Yes, the I want the vector of A*P multiplied again with P. Its for population dynamics. - user2008560
My guess is you mean (A^n)P. As Amro explains, the product of a vector and a matrix is another vector... - Buck Thorn
I think the answer by @TryHard is what you need, unless you really want something like this for N=4, A*P*P'*P*P' - Dennis Jaheruddin

1 Answers

1
votes

This is just a guess, but I think what you want is

PN = mpower(A,N)*P0

Here N is the generation number, P0 is the initial population vector.

As suggested by @LuisMendo and @DennisJaheruddin, this is equivalent to

PN = A^N*P0

To elaborate somewhat: at each generation you compute a new population from the old using Pnew = A*Pold, that is:

 P1 = A*P0                % generation 1
 P2 = A*P1 = A*A*P0       % generation 2
 P3 = A*P2 = A*A*A*P0     % generation 3

and so on, such that

 PN = (A*A*A*A...*A)*P0     % generation N
    = A^N*P0