Lecture_03_horowitz

Lecture_03_horowitz - 1 E7: INTRODUCTION TO COMPUTER E7:...

Info iconThis preview shows pages 1–14. Sign up to view the full content.

View Full Document Right Arrow Icon
E7 L3 1 E7: INTRODUCTION TO COMPUTER E7: INTRODUCTION TO COMPUTER PROGRAMMING FOR SCIENTISTS AND PROGRAMMING FOR SCIENTISTS AND ENGINEERS ENGINEERS Lecture Outline 1. Introduction to arrays 2. One-dimensional arrays 3. Character strings
Background image of page 1

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

View Full DocumentRight Arrow Icon
E7 L3 2 Introduction to arrays Introduction to arrays A simple array is an ordered collection of real numbers. MATLAB treats arrays very efficiently Input/output, indexing and addressing Arithmetic operations Other manipulations (e.g., sizing, reshaping, etc.) Arrays are the primary building blocks in MATLAB.
Background image of page 2
E7 L3 3 Introduction to arrays Introduction to arrays Examples 1-dimensional arrays: (1 row, 1 column) (1 row,4 columns) (3 rows, 1 [1] a = [ ] 1 5 3 2 b = - 2 1 3 c = -
Background image of page 3

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

View Full DocumentRight Arrow Icon
E7 L3 4 Introduction to arrays Introduction to arrays Examples: 2-dimensional arrays (2 rows, 3 columns) (3 rows, 3 columns) 2-D arrays will not be discussed in this lecture 1.2 3.2 1.0 3.1 92 0.0 d - = 1 4 6 7 2 5 8 4 3 e =
Background image of page 4
E7 L3 5 One-dimensional arrays One-dimensional arrays Those that have one row or one column. Construction: Manual Incremental linspace transpose: zeros ones rand/randn
Background image of page 5

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

View Full DocumentRight Arrow Icon
E7 L3 6 One-dimensional arrays – manual construction One-dimensional arrays – manual construction Row vectors: Syntax: [ element1 , element2 , ] >>r = [3,7,9] r = 3 7 9 , separates columns of an array [ starts the array ] ends the array [ ] 3 7 9 r =
Background image of page 6
E7 L3 7 One-dimensional arrays – manual construction One-dimensional arrays – manual construction Row vectors: Syntax: [ element1 element2 ] >>r = [3 7 9] r = 3 7 9 [ ] 3 7 9 r = columns can be separated by a space
Background image of page 7

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

View Full DocumentRight Arrow Icon
E7 L3 8 One-dimensional arrays – manual construction One-dimensional arrays – manual construction Column vectors: Syntax: [ element1 ; element2 ; ] >>c = [3;7;9] c = 3 7 9 ; separates rows of an array [ starts the array ] ends the array 3 7 9 c     =      
Background image of page 8
E7 L3 9 Row vectors – incremental construction Row vectors – incremental construction >> r = 3 : 2 : 10 r = 3 5 7 9 Syntax: first element : increment : limit [3,5,7,9]
Background image of page 9

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

View Full DocumentRight Arrow Icon
E7 L3 10 Row vectors – incremental construction Row vectors – incremental construction >> r = 3 : 2 : 10 r = 3 5 7 9 9 2 10 + | last element + increment | > | limit |
Background image of page 10
E7 L3 11 Examples – incremental construction Examples – incremental construction first element : increment : limit >> A = 1:1:10 A = 1 2 3 4 5 6 7 8 9 10 >> B = 1:10 B = 1 2 3 4 5 6 7 8 9 10 (first element : limit)
Background image of page 11

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

View Full DocumentRight Arrow Icon
E7 L3 12 Examples – incremental construction Examples – incremental construction first element : negative increment : limit >> C = 10 : -2 : -5 C = 10 8 6 4 2 0 -2 -4 | last element + increment | > | limit |
Background image of page 12
E7 L3 13 Linspace Linspace
Background image of page 13

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

View Full DocumentRight Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/17/2011 for the course ENGINEERIN 7 taught by Professor Patzek during the Spring '08 term at Berkeley.

Page1 / 49

Lecture_03_horowitz - 1 E7: INTRODUCTION TO COMPUTER E7:...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online