MATLAB Lecture hoolofMathematicalSciencesXiamenUniversityhttp://gdjpkc.xmu.edu.cn ts in the order 2 >>D=a(:,end); MATLAB→ Getting Started→ Matrices and Arrays→ Matrices and Magic Square The colon o 3. Array and Matrix Operations Operation MATLAB FormComments Array Addition a +b Array addition and matrix addition are identical Array Subtraction a-b Array subtraction and matrix subtration are identical Element-by-el multiplication array must be the same shape, or one of them must be a Matrix Matrix multiplication of a and b. The number of Multiplication columns in a must equal to the number of rows in b. or one of them must be a scal Righ / b a(ij)/b(1j) Division Both arrays must be the same shape, or one of them must be a scalar Left a b Element-by-element division of a and b b (ij)/b(i,j) Division Both arrays must be the same shape, or one of them nust be a scalar Matrix ght a/b DiⅤ ISion Matrix division defined by ab-I Matrix Left a\b Division Matrix division defined by a b Array Element-by-element exponentiation of a and b (i, j) u, Both arrays must be the same shape, or one of them must be a scalar > al eye[2, 2]8 obtain an identity matrix A1= 0 >>a2=[2,2;1,3]; >>al*a2 8 Matrix multiplication ans >>al.*a2 Element-by-element multiplication ans >>b1=[123];b2=[2311MATLAB Lecture 1 School of Mathematical Sciences Xiamen University http://gdjpkc.xmu.edu.cn Lec14 the elements in the order 2, 3, 1 >> D = a(:,end); MATLAB → Getting Started → Matrices and Arrays → Matrices and Magic Square → The Colon Operator 3. Array and Matrix Operations Operation MATLAB Form Comments Array Addition a + b Array addition and matrix addition are identical. Array Subtraction a b Array subtraction and matrix subtration are identical. Array Multiplication a .* b Elementbyelement multiplication of a and b. Both array must be the same shape, or one of them must be a scalar. Matrix Multiplication a * b Matrix multiplication of a and b. The number of columns in a must equal to the number of rows in b, or one of them must be a scalar.. Array Right Division a ./ b Elementbyelement division of a and b: a(i,j)/b(i,j). Both arrays must be the same shape, or one of them must be a scalar. Array Left Division a .\ b Elementbyelement division of a and b:b(i,j)/b(i,j). Both arrays must be the same shape, or one of them must be a scalar. Matrix Right Division a / b Matrix division defined by 1 ab- . Matrix Left Division a \ b Matrix division defined by 1 a b - . Array Exponentiation a .^ a Elementbyelement exponentiation of a and b: ( , ) ( , ) b i j a i j . Both arrays must be the same shape, or one of them must be a scalar. >> a1 = eye[2,2] % obtain an identity matrix A1 = 1 0 0 1 >> a2 = [2, 2; 1, 3]; >> a1*a2 % Matrix multiplication ans = 2 2 1 3 >> a1.*a2 % Elementbyelement multiplication ans = 2 0 0 3 >> b1=[1 2 3]; b2=[2 3 1];