class7b_while_loops_practice -   Launch MATLAB  ...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview:   Launch MATLAB   Access Blackboard In ­class Notes & Activities Class 7b   Download: ▪  class7b_matlab_activities.docx   Map a career account (H: Drive)   Set the computer aside Successful completion of this course will enable you to… use, create, and explore tools, particularly computer tools, in modeling, problem solving, and design. Successful completion of this course will enable you to:   Develop a logical problem solving process which includes sequential structures, conditional structures, and repetition structures for fundamental engineering problems,   Translate a written problem statement into a mathematical model,   Solve fundamental engineering problems using computer tools,   Perform basic file management tasks using an appropriate computer tool,   Employ design and problem processes in modeling, problem solving and design work,   Work effectively and ethically as a member of a technical team,   Develop a work ethic appropriate for the engineering profession,   Evaluate and provide feedback to improve solutions to engineering problems,   Reflect on personal and team performance to achieve continuous improvement, and   Demonstrate an ability to engage in continuing professional development. Individually, on a sheet of paper, no name (unless you want to get my attention)…   Think about your learning and your progression towards meeting the course goal and learning objectives…   Think about all elements of the course, including in ­class and out ­of ­class activities… Be Specific… 1.  What is helping you learn? 2.  What is not helping you learn? (Suggestions?)   Section 226 (n=120 ): Histogram of Exam 1 Scores   Course (N=1211): mean = 70.9 std = 14.3 Frequency mean = 70.4 std = 14.1 40 35 30 25 20 15 10 5 0 30 40 50 60 70 80 90 100 Exam Score By the end of topic, you will be able to   Use nested while…end loops   Create a while…end loop flowchart from a problem description   Write MATLAB while…end code from a flowchart   Interpret flowcharts and MATLAB code with while…end structures Loop WHILE the expression is true Exit the Loop once the test expression is false while…end MATLAB Program Structure while conditional_statement ... ... ... end Calculate the factorial value of any given number.   If a negative number is input, your function should return the value  ­1.   If zero is the input, your function should return the value 1 (as 0! = 1)   If a non ­negative, non ­zero number is input, your function should return the appropriate factorial value. counter = 1; factorial_value = 1; % You must check for negative numbers % You must check for inputnum=0 while counter <= input_number factorial_value=factorial_value*counter; counter = counter + 1; end % there are other solutions   Examples of While ­Loop uses:   Iterate until user terminates   Iterate until a computed result is achieved   Do NOT check for equality of computed quantities— rounding errors cause problems Example: x = 3.03 while x ~= 0 x = x - 1.01 end   Don’t simply check while error >= 0.01   large negative errors can result   must check for absolute value of error   Ctrl+C or Ctrl+Break to exit an infinite loop   Type the following into a file by name infinite_loop.m   Execute infinite_loop.m and explain the output input_number = 100; counter = 1; while counter<=input_number fprintf(‘Printing %i\n’,counter) end   What are some of the problems with infinite loops? Nested while…end Loops while conditional_statement1 ... while conditional_statement2 ------end ... ... end Nested while…end IMPORTANT: Initialize the test variable 1 before the while statement while conditional_statement1 ... IMPORTANT: Initialize the test variable 2 before the while statement while conditional_statement2 ----reassign the test variable 2 inside the loop --end reassign the test variable 1 inside the loop ... end   Access Blackboard In ­Class Activities & Notes Class 7b class7b_matlab_activities_engr195(II)s10.docx   Complete Activity 1 and 2 ...
View Full Document

Ask a homework question - tutors are online