Skip to main content
Engineering LibreTexts

11.5: Matrix Operations, Introduction

  • Page ID
    85030
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Here we will explore the algebra of matrices. It would be wise for the reader to have a basic knowledge of matrix algebra (or even linear algebra), but we will
    try and give plenty of explanatory examples.

    Just as for scalars, many of the common algebraic operations apply to matrices. The symbols + and − carry over quite nicely in “element-by-element” operations as one would expect (or at least hope for). Similarly, if you want element-by-element multiplication, division, or even exponentiation, these are given by .∗, ./ and .∧ (yes, those each have a preceding period and are pronounced “dot times”, “dot divide” and “dot exponent”). Operations like “regular” multiplication, division, exponents, etc. have a very different meaning than one who hasn’t been exposed to linear algebra might expect. We also have operations like the matrix transpose.

    Let’s look at some examples using the matrices A = [1 2 3 4;5 6 7 8] and B = [1; 6; 0; 9]. Again,
    A =
    1 2 3 4
    5 6 7 8

    and
    B =
    1
    6
    0
    9

    Example 11.4.1: Scalar Multiplication

    Here we show how to multiply every entry in a matrix by a scalar:

    >> A = [1 2 3 4;5 6 7 8];

    >> 3*A

    gives

    ans =
    3 6 9 12
    15 18 21 24

    One special operation for matrices is the matrix transpose, given by either transpose(A) or the shorter A'. The transpose of a matrix is another matrix with the rows and columns interchanged.

    Example 11.4.2: Transpose

    >> A = [1 2 3 4;5 6 7 8];

    >> A'

    ans =
    1 5
    2 6
    3 7
    4 8

    and

    >> B = [1; 6; 0; 9];B'

    ans =
    1 6 0 9

    The example A∧2 gives an error saying A must be square (here it is good to know some linear algebra), but A.∧2 gives element-by-element squaring:

    Example 11.4.3: Element by element squaring

    >> A = [1 2 3 4;5 6 7 8];

    >> A.∧2

    ans =

    1 4 9 16
    25 36 49 64

    Finally, we can create “block” matrices from smaller matrices by treating them as elements themselves and using the comma (or space) and the semicolon to create rows and columns. We just have to make sure the dimensions of the matrices line up properly. For example, we can stack two matrices.

    Example 11.4.4: Stacking Matrices

    >> A = [1 2 3 4;5 6 7 8];

    >> B = [1; 6; 0; 9];

    >> AoverBprime = [A ; B']

    AoverBprime =
    1 2 3 4
    5 6 7 8
    1 6 0 9


    This page titled 11.5: Matrix Operations, Introduction is shared under a CC BY-NC-SA 4.0 license and was authored, remixed, and/or curated by Troy Siemers (APEX Calculus) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.