Exam 3 Review

# Exam 3 Review - ENGR 101 Sec,on 100 Fall 10 Review...

This preview shows pages 1–7. Sign up to view the full content.

ENGR 101, Sec±on 100, Fall 10 12/12/10 1 Review: Programming in MATLAB ENGR 101: 13 Dec 10 Announcements Project 8 due tonight 9pm To be graded asap All regrade requests must be in before Final exam Exam 3 Thu 16 Dec, 8–10am open book & notes no computation or communication devices similar format to previous exams covers material to date, emphasis on MATLAB (all programming in MATLAB) Sample exams posted on Ctools Course evaluations

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
ENGR 101, Sec±on 100, Fall 10 12/12/10 2 Outline of Lectures Since Exam 2 15. Matrix calculations 16. Intro to MATLAB 17. Matrices in MATLAB 18. Scripts, Functions, Data 19. MATLAB Programming (Part I) 20. MATLAB Programming (Part II) 21. Subarrays and Vectorization 22. Visualizing Data 22a. Algorithmic trading 23. Fractals and the Mandelbrot Set C++ vs. MATLAB Compiled Fast Strongly typed Predefined libraries Variety of data types Graphics difficult Interpreted Slow Weakly typed Even more libraries Matrix based Easy graphics functionality
ENGR 101, Sec±on 100, Fall 10 12/12/10 3 Array as Fundamental Data Type To MATLAB all data is some kind of array. Scalars : arrays with one element (zero dimensions) Elements typically a floating-point or character type Vectors : sequence of scalars (one dimension, row or column) Matrices : two or more dimensions (rows, columns, …) Creating Matrices Matrices are specified in row order, separated by commas or spaces. Rows can be separated by semicolons (;) or new lines. a = [1.0, 3.0, 5.0; 2.0, 4.0, 6.0] b = [1.0 3.0 5.0 2.0 4.0 6.0 ]

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
ENGR 101, Sec±on 100, Fall 10 12/12/10 4 Accessing Array Elements Parentheses denote index operator ( ) unlike C++, MATLAB indices start at 1 Example: b = [1.0 3.0 5.0 2.0 4.0 6.0 ] b(1,3) 5.0 b(2,2) = 12 b = [1.0 3.0 5.0 2.0 12.0 6.0 ] MATLAB Workspace “main” scope for MATLAB functions and variable names Names introduced (e.g., initial assignment) and referenced from command window or script file Lifetime of names: from introduction until clear command Use who command to display active variables in workspace
ENGR 101, Sec±on 100, Fall 10 12/12/10 5 Read/Eval/Display Loop The MATLAB interpreter processes input (from keyboard or scripts) as follows: 1. read the next statement a command, assignment, or expression 2. execute the statement, eval uating expressions as needed 3. if an assignment or expression stmt, display the result unless statement ends in semicolon ( ; ) Read Eval Display Vectors with Constant Spacing The colon operator provides a shortcut for vectors with regular spacing first : increment : last x = 1:2:8; is equivalent to x = [ 1 3 5 7 ]; If increment is omitted, treated as 1 for example 1:4 is the vector [1 2 3 4]

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
ENGR 101, Sec±on 100, Fall 10 12/12/10 6 Colon Operator in Index Expressions a = [0 1 2 3 4 5 6 7 8 9] a(1) 0 a(8) 7 a(1:5) [0 1 2 3 4] a(4:10) [3 4 5 6 7 8 9] a(3:3:10) [2 5 8] Scalar Operations all binary, infix: Addition a + b Subtraction a b Multiplication a * b Division a / b Exponentiation a ^ b The same operations may also be applied to one array and one scalar (either order).
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 35

Exam 3 Review - ENGR 101 Sec,on 100 Fall 10 Review...

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

View Full Document
Ask a homework question - tutors are online