This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Lecture 1 Vectors, Functions, and Plots in Matlab In this book > will indicate commands to be entered in the command window. You do not actually type the command prompt > . Entering vectors In Matlab , the basic objects are matrices, i.e. arrays of numbers. Vectors can be thought of as special matrices. A row vector is recorded as a 1 n matrix and a column vector is recorded as a m 1 matrix. To enter a row vector in Matlab, type the following at the prompt ( > ) in the command window: > v = [0 1 2 3] and press enter. Matlab will print out the row vector. To enter a column vector type: > u = [9; 10; 11; 12; 13] You can access an entry in a vector with > u(2) and change the value of that entry with > u(2)=47 You can extract a slice out of a vector with > u(2:4) You can change a row vector into a column vector, and vice versa easily in Matlab using: > w = v (This is called transposing the vector and we call the transpose operator.) There are also useful shortcuts to make vectors such as: > x = 1:.1:1 and > y = linspace(0,1,11) Plotting Data Consider the following table, obtained from experiments on the viscosity of a liquid. 1 We can enter T (C ) 5 20 30 50 55 0.08 0.015 0.009 0.006 0.0055 this data into Matlab with the following commands entered in the command window: > x = [ 5 20 30 50 55 ] 1 Adapted from Ayyup & McCuen 1996, p.174....
View Full
Document
 Fall '08
 Young,T
 matlab, Vectors, Matrices

Click to edit the document details