Multiply a matrix n times

I have a Matrix M, which should be multiplied N times. I know I have to use M^N simply. (^ without the point) but the elements of the matrix M are also vectors so I get the following error:
Error using ^
Inputs must be a scalar and a square matrix.
To compute elementwise POWER, use POWER (.^) instead.
The code is similar to below:
M11 = exp(1j.*k1.*d1) .* (cos(k2.*d2) + 0.5j.*((k2./k1)+(k1./k2)).*sin(k2.*d2));
M12 = exp(-1j.*k1.*d1) .* (0.5j.*(k2./k1)-(k1./k2).*sin(k2.*d2));
M21 = exp(1j.*k1.*d1) .* (-0.5j.*(k2./k1)-(k1./k2).*sin(k2.*d2));
M22 = exp(-1j.*k1.*d1) .* (cos(k2.*d2) - 0.5j.*((k2./k1)+(k1./k2)).*sin(k2.*d2));
M = [M11 M12;M21 M22];
TransMat = M ^ N;
In the above code, k1 and k2 are vectors. when k1 and k2 are only a number, the error will solve. I have to find M^N for different values of k1 or k2.
Thanks in advance

1 Comment

Stephen23
Stephen23 on 10 Mar 2018
Edited: Stephen23 on 10 Mar 2018
@Matthew Morrison: what is your definition of matrix power for a non-square matrix? Please show a reference for how this should be calculated.

Sign in to comment.

Answers (0)

Asked:

on 10 Mar 2018

Edited:

on 10 Mar 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!