CS122 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Winter 2010.

Slides:



Advertisements
Similar presentations
Introduction to Programming using Matlab Session 2 P DuffourJan 2008.
Advertisements

CS123 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2012.
CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Winter 2010.
CSE 113 Introduction to Computer Programming Lecture slides for Week 10 Monday, October 31 th, 2011 Instructor: Scott Settembre.
Chapter 8 and 9 Review: Logical Functions and Control Structures Introduction to MATLAB 7 Engineering 161.
Today’s quiz on 8.2 B Graphing Worksheet 2 will be given at the end of class. You will have 12 minutes to complete this quiz, which will consist of one.
CS123 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Spring 2010.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University October 6-10, 2008 ©By the author. All rights reserved.
CS 122 Engineering Computation Lab Lab 2 Dan De Sousa and Tim Cheeseman Department of Computer Science Drexel University April 2009 ©By the author. All.
CS 121 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Fall 2009 ©By the author. All rights reserved. Permission.
CS122 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2011.
CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Spring 2011.
CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.
CS123 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Spring 2010.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Fall 2009 ©By the author. All rights reserved. Permission.
CSE 113 Introduction to Computer Programming Lecture slides for Week 12 Monday, November 14 th, 2011 Instructor: Scott Settembre.
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
CS 122 / CS123 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Summer 2011 ©By the author. All rights reserved.
CS 121 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Fall 2009 ©By the author. All rights reserved. Permission.
CS 123 Engineering Computation Lab Lab 2 Dan De Sousa and Bruce Char Department of Computer Science Drexel University April 2009 ©By the author. All rights.
CS122 Instructor Assignments Winter, 2010 Term. Overview Some changes in assignments due to schedule considerations Some new initiatives / revised strategies.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 ‏ Control Structures.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Fall 2010 ©By the author. All rights reserved. Permission.
CS122/CS123 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Summer 2011.
CS122 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Winter 2012.
CS 123 Lab 4 Instructor: Mark Boady Course Designer: Professor Bruce Char Department of Computer Science Drexel University Spring 2013.
CS122 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Spring 2011.
CS122 / CS123 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Summer 2011 ©By the author. All rights reserved.
Python 101 Dr. Bernard Chen University of Central Arkansas PyArkansas.
CS 121 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Fall 2011 ©By the author. All rights reserved. Permission.
CS123 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2010.
CS 121 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Fall 2010 ©By the author. All rights reserved. Permission.
CS 121 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Fall 2012 ©By the author. All rights reserved. Permission.
CS 121 Engineering Computation Lab Lab 3 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
CS123 Engineering Computation Lab Lab 1 Section Instructor: Mark Boady Content By: Bruce Char Department of Computer.
More Python!. Lists, Variables with more than one value Variables can point to more than one value at a time. The simplest way to do this is with a List.
CS 121 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Fall 2011 ©By the author. All rights reserved. Permission.
CS 121 – Quiz Feb 17 th. Question 2 We want to count how many days there were such that the temperature is at least degrees lower than the.
CS123 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Spring 2012.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Winter, 2011 ©By the author. All rights reserved.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Fall 2012 ©By the author. All rights reserved. Permission.
CS 122 Engineering Computation Lab Lab 4 Dan De Sousa and Bruce Char Department of Computer Science Drexel University Summer 2009 ©By the author. All rights.
Week 4 Program Control Structure
CS123 Engineering Computation Lab Lab 2 Instructor: Mark Boady Content By: Bruce Char Department of Computer Science Drexel University.
© The McGraw-Hill Companies, 2006 Chapter 3 Iteration.
CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Winter 2013.
CS 121 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Fall 2010 ©By the author. All rights reserved. Permission.
CS123 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2011.
CS122 – Quiz 2 Winter, 2013 Quiz Hints. Quiz 2 Hints Question 1 – working with the “if” statement  First, we did not fully explain the structure of the.
CS122 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Winter 2012.
CS 121 Engineering Computation Lab Lab 4 Department of Computer Science Drexel University February 16-20, 2008 ©By the author. All rights reserved. Permission.
CS123 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Spring 2013.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Winter 2011.
CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Winter 2012.
CS 122 Engineering Computation Lab Lab1 Bruce Char Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission.
CS 122/CS123 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Summer 2011 ©By the author. All rights reserved.
CS122 Engineering Computation Lab Lab 4 Bruce Char Department of Computer Science Drexel University Winter 2013.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Fall 2011 ©By the author. All rights reserved. Permission.
Matlab Training Session 4: Control, Flow and Functions
CS122 Engineering Computation Lab Lab 4
CS 121 Engineering Computation Lab Lab 3
CS123 Engineering Computation Lab Lab 4
CS122 Engineering Computation Lab Lab 3
CS 121 Engineering Computation Lab Lab 3
Review of Previous Lesson
Presentation transcript:

CS122 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Winter 2010

Review of Lab 2 Cycle Lab 2 – pre lab quizlet, lab 2 and quiz 2 completed along with pre lab 3 quizlet –Quiz grades to be issued this week –2nd chat session held on 2/01 – 0 attendees Major Lab 2 concepts to remember –Use of user defined functions to create plots of boxes –Introduction to Maple’s table and for loop features

Review of Lab 2 Cycle drawBoxB function syntax: –drawBoxB:=(width, length, xlo, ylo,c)  display([line([xlo,ylo],[xlo+width,ylo],color=c), line([xlo+width,ylo],[xlo+width,ylo+height],color=c), line([xlo,ylo],[xlo,ylo+height],color=c), line([xlo,ylo+height],[xlo+width,ylo+height],color=c)], axes=none, scaling=constrained);

Review of Lab 2 Cycle Maple table and for loop usage in the chemical reaction problem –Atab:=table(); –indexTab:=table(); –for i from 1 to 50 do indexTab[i] := i; # note use of for loop counter I Atab[i] := ………..; Etc. –end do; –# remember to convert tables to lists before using in plot functions –# since these functions expect a list type parameter

Administrative Notes Please continue to contact your individual instructors with questions and problems Will determine and communicate future of on-line chat sessions – what additional lab / quiz support activities would be helpful – current activities include: –CLC consultation –Quiz hint slides –Chat sessions –Special (by invitation) extra consultation

Lab 3 Overview Based on materials from Chapter 12 and 13 readings –Chapter 12 – More on repetition and looping “while” loop – conditional looping + relational operators Combining “for” and “while” loops Dealing with runaway (infinite) “while” loops –Chapter 13 – Conditional execution Choosing alternatives – if.. then.. else.. elif constructs

Lab 3 Overview Lab 3 outline –Part 1 – Analysis of Blammo trajectory options Applying a “for” loop to calculate Blammo’s distance for a variety of firing angles – starter script provided 1.2 – Finding the smallest firing angle for Blammo to achieve a particular flight distance 1.3 – Find all firing angles that enables Blammo to hit target 1.4 – Plot a movie (animation) of all trajectories for different firing angles

Lab 3 Overview Lab 3 outline –Part 2 – Movement of a particle within a box Create a movie of a particle bouncing of the East wall of a box (using the drawBoxB function from Lab 2) 1.2 – Extend the 1.1 script to also bounce off of West wall 1.3 – Extend the 1.2 script to also bounce off of the North and South walls 1.4 – Create a movie using a “non-square” box and diagonal particle movement

Lab 2 Maple Concepts: Discussion and Demo Conditional looping with “while” loops –while (condition) do loop body –end do; –The loop body will continue to get executed as long as the condition = true –The condition expression usually utilizes 1 or more relational operator ( >= <> = ) –Sometimes, a variable in the condition expression must be initialized so that it will have a value for the 1 st condition test –Faulty program logic can result in an endless (infinite) loop Use “stop (red)” hand on Maple icon list If this does not stop the execution, use “Force quit” from the Maple menu

Lab 2 Maple Concepts: Discussion and Demo “while” loops - continued –“while” and “for” loops can be used in combine when you want to potentially loop over a series of values, but also want to stop when a certain condition is met. –ex.  for angle from 0 to 90 while (cos >= sin) do This loop has the potential to loop 91 times But will stop looping once cos < sin. In some iteration (angle = 45), the cos and sin will become equal. Before, the cos is > sin and after, the cos < sin. Therefore, this loop will execute 46 times, for angles of 0 through 45

Lab 2 Maple Concepts: Discussion and Demo Choosing among alternative actions – “if” statement –if (condition) then Code to execute if condition is true –end if; –if (condition) then Code to execute if condition is true –else Code to execute if condition is false –end if; –Many examples in chapter readings, demo and lab

Lab 2 Maple Concepts: Discussion and Demo Choosing among cases – if-then-elif-else-end –if (condition1) then Code to execute if condition1 is true –elif (condition2) then Execute if condition2 is true Note – only can reach here if condition 1 was false –elif (condition3) then if condition 3 true (1 and 2 were false) –else “catch all” bucket – if all case conditions specified above were false –end if; See chapter 13 for examples of this construct

Lab 2 Maple Concepts: Discussion and Demo Animation / Movie basics An animation is actually a series of “snapshot” plots which are displayed one by one to give the appearance of a continuous “movie” –“insequence=true” in the display function designates the plots as an animated sequence –When executed, the initial plot in the sequence appears on the screen. By “right-clicking” on this plot and selecting Animate  Play The animation will run (see demo for example animation) Note the overall syntax and order of operations in the demo example!

Lab 2 Maple Concepts: Discussion and Demo Use of the ptpos (list) variable in Part 2 of today’s lab –ptpos[x,y] is a list that represents a point in the X-Y grid with an x coordinate = x and y coordinate = y –ptpos[9,1] indicates a point within the box whose location in a 10x10 box will be at x=9 and y=1 –To access the x component of the point  ptpos[1] –Likewise, the y component is accessed  ptpos[2]

Lab 3 Maple Concepts: Discussion and Demo Demo of Maple features needed for this lab –Open the Maple worksheet demo file form the course web site CS122Lab3Demo.mw –The following concepts are illustrated Example 1 – produce table of sine and cosines functions for angles from 0 to 90 degrees Example 2 – script to find and report the angle between 0 and 90 degrees for which the sine and cosine are equal Example 3 – produce table of sines and cosines for angles between 0 to 90 where cosine is greater than sine Example 4 – Create a movie of sine and cosine values for 0 through 90 degrees

Quiz Week (6) Activities Quiz 3 will be released on Friday (2/12) at 6 PM –Deadline: Wednesday (2/03) at 4:30 PM) –Makeup quiz – from Thursday (2/17) at 9 AM through Sunday (2/21) at 11:30 PM 30% penalty Pre-lab 4 quizlet –From Thursday (2/17 – 9 AM) through Monday (2/22 – 8 AM) Be sure to visit the CLC for quiz assistance Next chat – we will communicate status via