0% found this document useful (0 votes)
83 views2 pages

Introduction To Vectors in Matlab

This document provides a basic introduction to working with vectors in Matlab. It explains how to start Matlab, create vectors using notation like 0:2:8, assign vector names, perform operations on vectors like transposes and indexing specific elements, and do basic arithmetic on vectors. Vectors in Matlab are central to working with matrices and performing operations that are important for linear algebra.

Uploaded by

MeddyDanial
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views2 pages

Introduction To Vectors in Matlab

This document provides a basic introduction to working with vectors in Matlab. It explains how to start Matlab, create vectors using notation like 0:2:8, assign vector names, perform operations on vectors like transposes and indexing specific elements, and do basic arithmetic on vectors. Vectors in Matlab are central to working with matrices and performing operations that are important for linear algebra.

Uploaded by

MeddyDanial
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Introduction to Vectors in Matlab

This is the basic introduction to Matlab. Creation of vectors is included with a few basic operations. Matlab is a software package that makes it easier for you to enter matrices and vectors, and manipulate them. The interface follows a language that is designed to look a lot like the notation use in linear algebra. In the following tutorial, we will discuss some of the basics of working with vectors. To start matlab, open up a unix shell and type the command to start the software: matlab. This will start up the software, and it will wait for you to enter your commands. In the text that follows, any line that starts with two greater than signs (>>) is used to denote the matlab command line. This is where you enter your commands. Almost all of Matlabs basic commands revolve around the use of vectors. To simplify the creation of vectors, you can define a vector by specifying the first entry, an increment, and the last entry. Matlab will automatically figure out how many entries you need and their values. For example, to create a vector whose entries are 0, 2, 4, 6, and 8, you can type in the following line:
>> 0:2:8 ans = 0 2 4 6 8

Matlab also keeps track of the last result. In the previous example, a variable "ans" is created. To look at the transpose of the previous result, enter the following:
>> ans' ans = 0 2 4 6 8

To be able to keep track of the vectors you create, you can give them names. For example, a row vector v can be created:
>> v = [0:2:8] v = 0 >> v v = 2 4 6 8

0 >> v; >> v' ans = 0 2 4 6 8

Note that in the previous example, if you end the line with a semi-colon, the result is not displayed. This will come in handy later when you want to use Matlab to work with very large systems of equations. Matlab will allow you to look at specific parts of the vector. If you want to only look at the first three entries in a vector you can use the same notation you used to create the vector:
>> v(1:3) ans = 0 >> v(1:2:4) ans = 0 4 2 4

>> v(1:2:4)' ans = 0 4 Once you master the notation you are free to perform other operations: >> v(1:3)-v(2:4) ans = -2 -2 -2

You might also like