Class Notes (838,007)
United States (325,259)
ENG 6 (40)
Lecture 5

# ENG 06 – Lecture 5 notes.docx

5 Pages
53 Views

Department
Engineering
Course
ENG 6
Professor
A H M E D R A W Y
Semester
Spring

Description
ENG 06 – Lecture #5; 1/22/2013 Plotting  ginput o displays coordinates where a user clicked on a graph  Saving plots o File -> save as  Change file to format like jpg  Histogram o hist function o two arguments: data set, followed by number of bins (default is 10) o also functions for pie charts, box and whisker plots o search “specialized plotting”  3-D Plotting o plot3() command o 3 vectors, x, y, and z o You can also plot surfaces o Use meshgrid to generate matrices of points for z o Use mesh or surf functions to plot surface o Create top-down view of surface‟s elevations using pcolour or contour  3-D Line Plot  3_D surfaces: meshgrid o 1 variable as a function of x and y o for every possible combo of x and y, you need a z value o plot a surface for x and y from 0 10 10, create meshgrid o [x y] = meshgrid(-10:10, -10:10); o z = x.^2-y.^2; o mesh(x,y,z);  3_D surfaces: surf o fills in surface  3-D surfaces: Pseudo color plot o 2 d value represented by color o use pcolour  3-D surfaces: contour plot o if you want to just display lines that connect points of the same z elevation o additional examples: type demo in command window, scroll down to graphics Review/Advanced/Details: Vectors  Vectors: Indexing o Process of extracting or inserting values in a vector o Syntax:  V(index) returns element(s) at location specified by index  V(index) = value replaces elements at specified locations  Numerical Indexing o Indexing vector can be any length of integers  Replacement Rules: o Either  All dimensions on either side of replacement instruction must be equal, or  There must be a single element on right side of replacement o If you replace beyond end of existing vector, vector length is increased  Other elements become 0  Caution: shortening a vector o Better to extract what you want by indexing than removing what you don‟t want o Assign empty vector [] to elements of a vector  Operating on vectors o Arithmetic operations, logical operations, and applying library functions  Library Functions: o Sum(v) and mean(v) consume a vector and return a number o Min(v) and max(v) return two quantities: minimum or maximum value and the position in the vector o Round, ceil,floor, fix remove fractional part of numbers  Concatenation o You can construct a new vector by concatenating (combining) other vectors o A = [B C D…X Y Z] o Individual items in brackets may be any vector defined as a constant or variable o Length of A will be sum of lengths of individual vectors  Slicing (generalized indexing) o B()=A()  A is an existing array, B can be an existing array or a new array  Values in B at indices in are assigned values of A from Review/Advanced/Details:Arrays  Resources: create elementary matrices: o Zeros o Ones o Eye: identity matrix o Linspace: linearly spaced vector o Logspace: logarithmically spaced vector o Meshgrid: x and y arrays for 3-D plots  Arrays: Indexing o A(row, col) returns elements at location specified o A(row, col) = value replaces elements at specified location o Indexing row and column vectors may contain either numerical or logical values  Arrays: Numerical Indexing o Indexing vectors can be of any length, include integers o For reading elements: 1<=element<=length(array dimension) o For replacing elements: 1<=element  Arrays: Replacement Rules o Same as vectors  Operating on Arrays o Same techniques as vectors with:  Arithmetic operations, logical operations, library functions, slicing o Concatenation is treated slightly differently  R = [A B C] is fine as long as A,B, and C have the same number of rows  R = [A;B;C] is fine as long as A, B, and C have the same number of columns  Matrix Multiplication‟ o Using * by itself on matrices performs matrix multiplication o A*b element in first row, second column of result is sum of each element of first
More Less

Related notes for ENG 6
Me

OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Just a few more details

So we can recommend you notes for your school.