A=[1 2;-4 5] 3*A
Here is another example
A=floor(10*rand(3)); B=floor(10*rand(3)); C=floor(10*rand(3)); D=A*(2*B-3*C)
A=[2 3 -1;5 8 2] B=[9 5 1;2.1 5 8]
then
C=A+i*B
gives the matrix with entries [A(i,j)+sqrt(-1)*B(i,j)].
A=[2 1;0 -2] eye(2) B=A+eye(2) C=A+1
A=[2 3 -1;5 8 2;0 1 -2] B=A^3
det(A)
If A is nonsingular , then the inverse in Matlab is given by inv(A) or A^(-1). More generally, in the nonsingular case, you can compute A^(-r).
A=[2 1;0 -2] B=A^2+2*A+eye(2)
Suppose A is an n by n square matrix, c is an n component row vector and b is an n component column vector, then the following calculation gives a scalar f=c*(A^3+A^2+A)*b
A=[2 1;0 -2] c=[1 2] b=[1 -1]' f=c*(A^3+A^2+A)*b
On the other hand, it is much more efficient to write
g=c*(A*(A*(A*b+b)+b))
To see this redo the two examples using the flops command
A=[2 1;0 -2] c=[1 2] b=[1 -1]' flops(0) f=c*(A^3+A^2+A)*b f_flops=flops; flops(0) g=c*(A*(A*(A*b+b)+b)) g_flops=flops; disp([f_flops g_flops])
The basis for this difference is Horner's method (or synthetic division).
C=A.*B has entries c(i,j)=a(i,j)b(i,j) C=A./B has entries c(i,j)=a(i,j)/b(i,j) C=A.\B has entries c(i,j)=b(i,j)/a(i,j) C=A.^B has entries c(i,j)=a(i,j)^{b(i,j)} C=A.^r has entries c(i,j)=a(i,j)^r where r is a number. C=r.^A" has entries c(i,j)=r^{a(i,j)}
For example,
A=[2 1;3 -2] B=[-4 1;3 2] C=A./B D=A.^B E=A.^2 F=2.^B
sin(A*pi/2) exp(B*pi*i) log(B)
As you can see these operations also take place componentwise; that is, the function is applied to each entry. This is very useful for numerical programming.