Search the courses, subjects, tracks, games and features, or jump straight to a page.
Learn it your way
A short class with Sarah and her students. The other ways are under More.
Sign up free to listen. Transcripts are free to read.
Today, we will learn how to enter vectors in MATLAB. Vectors are essentially one-dimensional matrices. Can anyone tell me what a row vector looks like in MATLAB?
Isn't it formed by typing the numbers inside square brackets and separating them by spaces?
Exactly! For example, you can create a row vector like this: v = [1 4 7 10 13]. What about column vectors? How are they different?
Column vectors require semicolons between the elements, right?
Yes! For example, w = [1; 4; 7; 10; 13] creates a column vector. Great job!
Now, let's discuss transposing. When would we need to transpose a vector?
When we want to change a row vector to a column vector, right?
Exactly! You can achieve this by using the apostrophe operator. For example, if you have a row vector v, you can create a column vector with w = v'. Who can show me how to check the first element of w?
You would type w(1) to access the first element!
Perfect! Always remember that indexing starts from 1 in MATLAB.
Now that we have vectors, how can we access specific elements, say the first three elements of a vector v?
We can use the colon operator, like v(1:3).
Correct! And if you want to access elements from a specific point to the end? What would that syntax look like?
We could write v(3:end) to get elements from the third to the last.
Well done! Remember, end helps you access the last element without needing to know its index.
Let’s recap what we’ve learned about entering vectors. What are the two types of vectors we've discussed?
Row vectors and column vectors!
Right! And how do we create a column vector?
By using semicolons to separate the elements in the brackets!
Exactly! Now for your practice, try writing a vector and accessing its elements using colon notation. Don't forget to reflect on how each concept fits into our overall understanding of matrices.
A one-dimensional array in MATLAB created using square brackets with spaces separating elements.
A one-dimensional array in MATLAB created using square brackets with elements separated by semicolons.
An operation that flips the matrix dimensions from row to column or vice versa.
The method of accessing elements in a vector using their designated positions.
To create a row with numbers in line, use brackets, spaces, everything will align.
Imagine a row of books on a shelf (the row vector) and another pile of books standing up (the column vector), showing how they can stand or lie down depending on how we arrange them in MATLAB.
Use a 'C' for Column (semicolon) and an 'R' for Row (space or comma) to recall how to create each vector type!
VARS: Vectors Are Row or Column Separated.
Term
How do you create a column vector in MATLAB?
Click to flip
Term
What does the transpose operator do?
Click to flip
A one-dimensional array in MATLAB with dimensions 1 x n, created using square brackets and spaces or commas.
A one-dimensional array in MATLAB with dimensions m x 1, created using square brackets and separated by semicolons.
An operation in MATLAB indicated by an apostrophe that changes a row vector into a column vector and vice versa.
A MATLAB syntax for accessing a range of elements within a vector or matrix.
Referring to elements in an array by their position using parentheses.
This section explains how to create and manipulate vectors in MATLAB, including row and column vectors.
The section discusses the fundamental methods for entering vectors in MATLAB, detailing the syntax for both row and column vectors, accessing elements, and vector operations like transposition.
In MATLAB, vectors are a special case of matrices defined as one-dimensional arrays. A row vector has the dimension 1 × n (one row and n columns), while a column vector has the dimension m × 1 (m rows and one column). Vectors in MATLAB are denoted using square brackets, with elements separated by spaces or commas for row vectors and semicolons for column vectors.
v = [1 4 7 10 13].w = [1; 4; 7; 10; 13].v(1) retrieves the first element of vector v.v(1:3) for the first three elements and v(3:end) for all elements from the third to the last.This section lays the groundwork for understanding matrix and vector manipulations in MATLAB, which is crucial for further mathematical computations.