lecture1

# lecture1 - Lecture 1 Vectors, Functions, and Plots in...

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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Lecture 1 Vectors, Functions, and Plots in Matlab In this book &gt; will indicate commands to be entered in the command window. You do not actually type the command prompt &gt; . 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 ( &gt; ) in the command window: &gt; v = [0 1 2 3] and press enter. Matlab will print out the row vector. To enter a column vector type: &gt; u = [9; 10; 11; 12; 13] You can access an entry in a vector with &gt; u(2) and change the value of that entry with &gt; u(2)=47 You can extract a slice out of a vector with &gt; u(2:4) You can change a row vector into a column vector, and vice versa easily in Matlab using: &gt; w = v (This is called transposing the vector and we call the transpose operator.) There are also useful shortcuts to make vectors such as: &gt; x = -1:.1:1 and &gt; 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: &gt; x = [ 5 20 30 50 55 ] 1 Adapted from Ayyup &amp; McCuen 1996, p.174....
View Full Document

## lecture1 - Lecture 1 Vectors, Functions, and Plots in...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online