Linear Equations -- JHU MATLAB Help Page
LINEAR EQUATIONS
 

Creating a Matrix
Substituting Within a Symbolic Matrix
Manipulating Regular Matrices
Vectors
Scalar Multiplication
Addition of Matrices
Gauss-Jordan Elimination
Reduced Row-Echelon Form
Dot Product
Rank
Number of Solutions
Vectors
How to Examples Exercise
How to:
Vectors are simply a special type of matrix that have only one row (1xN) or one column (Nx1).
Creating a vector is no different than
creating a regular matrix:
     rV = [Row vector entries etc.] or
     cV = [Column; vector; entries; etc.]


But, we can also separate a row or column vector from a matrix by utilizing the colon operator:
     rV = A(i, :) (the i-th row of matrix A) or
     cV = A(:, j)
(the j-th column of matrix A)



Examples:
Let's create 2 vectors, one a row vector and one a column vector, whose entries are 1, 2, and 3. For the row vector we have:
     rV = [1 2 3]
And for the column vector:
     cV = [1; 2; 3]

Now, let's create the same vectors, but this time by copying them from the matrix, R, with 10, 1, 13 in the first row, 1, 2, 3 in the second row, and 9, 3, 11 in the third row. You can see that the second row has 1, 2, 3 just like we want:
     rV = R(2, :)
Also, reading down the second column, we see 1, 2, 3 in order as well:
     cV = R(:, 2)


Exercise:
Given a matrix A = [4 7 8; 0 0 3; 8 7 9], extract from it a column vector with values 8, 3, 9.

Click here to see the answer.