13.3: Vectors in MATLAB

Fundamentals of MATLAB Programming · LibreTexts

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    Read aloud

    How

    Speed: 1×
    Light up
    Highlight

    Symbols: Mulberry Symbols, © 2018–2026 Steve Lee, CC BY-SA 4.0 (licence, the set), the site's own copies.

    From LibreTexts, under CC BY-NC-SA, as the source states it; its equations are written in TeX, which the PDF shows typeset. This page at LibreTexts.

    13.3: Vectors in MATLAB

    A vector is a one-dimensional array of numbers. In mathematics and physics, a vector often represents a quantity that has both magnitude and direction. Examples include displacement, velocity, acceleration, and force.

    In MATLAB, we can store a vector as either a row vector or a column vector. A row vector has one row and several columns. A column vector has several rows and one column.

    vRow = [3 2 5]  % A row vector
    
    vCol = [3; 2; 5]  % A column vector

    Both vectors contain the same three numbers, but their shapes are different. This matters in matrix operations, especially when multiplying matrices or solving systems of equations.

    Note

    Use spaces or commas to separate entries across a row. Use semicolons to move to the next row. For example, [3 2 5] is a row vector, while [3; 2; 5] is a column vector.


    This page titled 13.3: Vectors in MATLAB was last modified on Tue, 30 Jun 2026 02:11:58 GMT and is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Zara Noroozi.