Presentation is loading. Please wait.

Presentation is loading. Please wait.

General Computer Science for Engineers CISC 106 Lecture 08 James Atlas Computer and Information Sciences 9/21/2009.

Similar presentations


Presentation on theme: "General Computer Science for Engineers CISC 106 Lecture 08 James Atlas Computer and Information Sciences 9/21/2009."— Presentation transcript:

1 General Computer Science for Engineers CISC 106 Lecture 08 James Atlas Computer and Information Sciences 9/21/2009

2 Objectives Use Recursion to Solve Problems Understand collections of data in Matlab Arrays/Matrices

3 Recursive Function Function that refers to itself Example: sum numbers 1 to n function out=sum(n) if n < 1 out = 0; else out = n + sum(n - 1); Termination Condition Simplify Problem, Assemble Results

4 Fibonacci Sequence F n = F n-1 + F n-2 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,... each number is the sum of the two previous numbers

5 123123123123 5813 2134

6

7

8 Fibonacci Sequence F n = F n-1 + F n-2 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,...

9 Newton’s Method

10 x n+1 = x n - f(x) / f’(x) x n+1 = x n - (x n 2 - r) / 2x n

11 Arrays

12 Arrays

13 Arrays Fundamental unit of data in MATLAB Collection of data into rows and columns (MATrix LABoratory) 1 dimensional, vector 2 dimensional, matrix 0 dimensional, scalar (a 1x1 array)

14 Arrays

15 Array commands a = [1 2 3 4] b = [1; 2; 3; 4] c = [1 2; 3] (error) d = [1 2; 3 4] f = d(1,2) g(4,5) = 7 a(2:end) d’

16 Arrays continued zeros(), ones(), eye() scalar vs. array arithmetic +, -, * (.*), / (./) ^ etc.


Download ppt "General Computer Science for Engineers CISC 106 Lecture 08 James Atlas Computer and Information Sciences 9/21/2009."

Similar presentations


Ads by Google