You are on page 1of 2

%% Lecture 5 Addition Operation

x=[1 2;3 4];


E= x- 5; % subtract 5 from all the elements
E1=x+25; % add 25 to all the elements
E2=x-15;

%% Element by Element Multiplication


A = [1 2;1 3];
B = [2 2;2 1];
B1=A^2; % A*A
B2=A*A; % Multiplication
C1 =A.^2; % Each Element to power 2
C = A.*B;
C2=A*B;

%% Array Division Left & Right Division


a=[1 2;1 3];
b=[2 2;2 1];
c=a./b; % elements of a matrix is divided by
each element of b matrix
c1=a.\b;% elements of b matrix is divided by
each element of a matrix
c2=a/b; % this is multiplication means a mtrix
is multiplied with b inverse

%% Sum of Matrices
Y=[2 3;4 4];
Z=[3 4;5 9];
Sum=Y+Z;
Sum1=plus(Y,Z);
%% Subtraction of Matrices
Y=[2 3;4 4];
Z=[3 4;5 9];
Sub=Y-Z;
Sub1=minus(Y,Z);

%% Multiplication of Matrices
Y=[2 3;4 4];
Z=[3 4;5 9];
Mul=Y*Z;
Mul1=mtimes(Y,Z);

You might also like