Opening the book…
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.
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.
The book could not be loaded just now.