Download presentation
Presentation is loading. Please wait.
Published byAmanda Goodwin Modified over 9 years ago
1
MECE 102: Engineering Mechanics Lab A First Year Course in Newtonian Mechanics, Experimentation, and Computer Tools Created by the Faculty of the Mechanical Engineering Department in the Kate Gleason College of Engineering at RIT
2
Week 13 Lecture Programming Skills This week we will: Investigate programming Loops utilizing For Loops Iterated Loop While Loop Conditional Loop Use Matlab and LabView to program an algorithm to calculate sin
3
iCLICKER: Which of the following concepts is NOT relevant to utilize for this week’s Programming activities? Select your Answer: A.Recursion B.Algorithm C.Newton’s 2 nd Law D.Flow Chart E.None of the above
4
iCLICKER: Which of the following concepts is NOT relevant to utilize for this week’s Programming activities? Select your Answer: A.Recursion B.Algorithm C.Newton’s 2 nd Law D.Flow Chart E.None of the above
5
ASSUME: Problem A: Calculus description of sine function Recall from Calculus: Our goal is to write code that approximates the sine function:
6
FORMULATE: Problem A: State the Known and Desired Information Approximate sin by using a known finite number of terms, N.
7
CHART: Problem A: Flow Chart of Finite Sum Algorithm
8
This block defines variables and initializes values.
9
CHART: Problem A: Flow Chart of Finite Sum Algorithm This block defines variables and initializes values. Finite number of Loops set “a priori”
10
CHART: Problem A: Flow Chart of Finite Sum Algorithm This block defines the FOR iterated loop and sine equation
11
CHART: Problem A: Flow Chart of Finite Sum Algorithm CONDITIONAL evaluation of Loop
12
EXECUTE: Problem A: Calculating the Finite Sum employing Recursion The calculation of the sine equation can be expanded as: Where each term can be written as T i
13
EXECUTE: Problem A: Calculating the Finite Sum employing Recursion Starting at i = 0, the first 6 terms can be written as: Use of Recursive relationship to calculate terms
14
EXECUTE: Problem A: Calculating the Finite Sum employing Recursion Using the concept of a Recursive relationship, we can efficiently write each new term, T i, as a function of the preceding term, T i-1 :
15
EXECUTE: Problem A: Matlab FOR loop example code The following code are examples of utilizing a FOR loop: for i from start to stop do body of program end_for for i from start to stop step stepwidth do body of program end_for
17
FORMULATE: Problem B: State the Known and Desired Information Approximate sin by using a convergence criteria of relative error.
18
iCLICKER: The value of acceptable error, , is NOT dependent on the limit of the computer system analyzing the program. Select your Answer: A.True B.False
19
iCLICKER: The value of acceptable error, , is NOT dependent on the limit of the computer system analyzing the program. Select your Answer: A.True B.False The value of the acceptable error, , should be chosen to be small enough for engineering accuracy, however large enough to avoid issues with the computer accuracy limit.
20
ASSUME: Problem B: Identify the Convergence Criteria Relationship The WHILE loop will terminate once the relative error is less than some acceptable error limit, . This is known as the convergence criteria of relative error.
21
Conversion accuracy issue ….. Convert [101011.01101] base 2 to a base 10 number ….
22
Conversion accuracy issue ….. Convert [39] base 10 to a base 2 number ….
23
Conversion accuracy issue ….. Convert [39.9] base 10 to a base 2 number ….
24
iCLICKER: Approximately how many significant digits of accuracy are associated with a 64 bit computer? Select your Answer: A.~ 2 significant digits B.~ 7 significant digits C.~14 significant digits D.~ 21 significant digits
25
iCLICKER: Approximately how many significant digits of accuracy are associated with a 64 bit computer? Select your Answer: A.~ 2 significant digits B.~ 7 significant digits C.~14 significant digits D.~ 21 significant digits
26
CHART: Problem B: Flow Chart of Conditional Sum Algorithm
27
This block defines variables and initializes values.
28
CHART: Problem B: Flow Chart of Conditional Sum Algorithm This block defines variables and initializes values. Acceptable error defined “a priori”
29
CHART: Problem B: Flow Chart of Conditional Sum Algorithm This block defines the WHILE loop and sine equation
30
CHART: Problem B: Flow Chart of Conditional Sum Algorithm CONDITIONAL evaluation of Loop
31
EXECUTE: Problem B: Relative Error For an alternating series summation, we can estimate the error, e, between successive terms as the magnitude of the last term in the sequence.
32
EXECUTE: Problem B: Matlab WHILE loop example code The following code are examples of utilizing a WHILE loop: while condition do body of program end_while This loop evaluates its body while a specified condition is TRUE.
33
LabVIEW Video
34
Homework Uniform Circular Motion Lab Report due tonight! Prior to LAB tomorrow Read section 13.2 of the textbook Watch LAB Videos Complete the on-line LAB quiz in myCourses Attempt to solve Homework problem 13.1 in your logbook before RECITATION. This is a Programming extension of the work in Chapter 13 Include in your Logbook your algorithmic Flow Chart, Computer program code, and an example of your Output.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.