ME 123 Lecture - Rose

Download Report

Transcript ME 123 Lecture - Rose

ME 123
Computer Applications I
Lecture 16:
More Matlab Programming: Secant Method, Review
4/4/03
Reminder
• Exam 1 will be on next Monday (closed book, closed notes,
closed computer)
Lecture 16
ME 123 Computer Applications I
2
Recapitulation of Lecture 15
•
In the last lecture, we did not learn new Matlab command. Instead we apply what
we have learned so far to program a root finder using the bisection method.
•
Homework feedback:
– Comparison between Problem 2 and Problem 3 indicates that some of you have
difficulty with understanding the problem statement, NOT the programming part.
– Apply the flow chart methodology every time before you start any programming.
– Sequential thinking: the order of your procedure matters a lot!
Lecture 16
ME 123 Computer Applications I
3
Road Map of Lecture 16
•
Solutions to HW 4-3
•
More Matlab programming exercise: root finding
– the secant method: variant of the bisection method, make use of the
information on functional value
– work out flow chart with students
• Review for Exam 1
Lecture 16
ME 123 Computer Applications I
4
“Crude” Flow Chart for Secant Method
Input left and right bounds
no
Check to make sure they bound the root (How?)
yes
Compute the approximate root (How?)
Check if the app. root and the lower bound sandwich the root (How?)
yes
no
upper bound = app. root
Lecture 16
lower bound = app. root
ME 123 Computer Applications I
5
Review for Exam 1
• Definition of scalar, vector, matrix; naming convention
• 2-D plotting (line, marker, labeling, legend, etc.)
• Input/Output (command line, data file, etc.)
• User defined function (input/output list), m-file
• Solution to system of equations
• if statement, relational operators
• for loop
• switch statement
• while loop
Lecture 16
ME 123 Computer Applications I
6