CS122 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Spring 2011.

Slides:



Advertisements
Similar presentations
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
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.
COP4020/CGS5426 Programming languages Syllabus. Instructor Xin Yuan Office: 168 LOV Office hours: T, H 10:00am – 11:30am Class website:
CS123 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Spring 2010.
Introduction to Information and Computer Science Computer Programming Lecture d This material (Comp4_Unit5d) was developed by Oregon Health and Science.
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.
1 Functions 1 Parameter, 1 Return-Value 1. The problem 2. Recall the layout 3. Create the definition 4. "Flow" of data 5. Testing 6. Projects 1 and 2.
CS 121 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Fall 2012 ©By the author. All rights reserved. Permission.
CS 121 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Fall 2009 ©By the author. All rights reserved. Permission.
CS 121 Engineering Computation Lab Lab 1 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.
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.
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.
CS122 Instructor Assignments Winter, 2010 Term. Overview Some changes in assignments due to schedule considerations Some new initiatives / revised strategies.
CS 240 – Computer Programming I Lab Kalpa Gunaratna –
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.
Introduction to Loops For Loops. Motivation for Using Loops So far, everything we’ve done in MATLAB, you could probably do by hand: Mathematical operations.
CS122 / CS123 Engineering Computation Lab Lab 4 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 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.
ENG College of Engineering Engineering Education Innovation Center 1 Basic For Loops in MATLAB Programming in MATLAB / Chapter 6 Topics Covered:
CSS 290: Video Games and Computer Programming. CSS 2902 Reading: Conditional Statements PLAD Ch 4 –The objective for this book is to provide you with.
CS 121 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Fall 2012 ©By the author. All rights reserved. Permission.
CS112 Scientific Computation Department of Computer Science Wellesley College Loops Iteration with for loops.
CS 121 Engineering Computation Lab Lab 3 Department of Computer Science Drexel University Summer 2009 ©By the author. All rights reserved. Permission is.
CS123 Engineering Computation Lab Lab 1 Section Instructor: Mark Boady Content By: Bruce Char Department of Computer.
CS 121 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Fall 2011 ©By the author. All rights reserved. Permission.
CS 121 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Fall 2011 ©By the author. All rights reserved. Permission.
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.
CS123 Engineering Computation Lab Lab 2 Instructor: Mark Boady Content By: Bruce Char Department of Computer Science Drexel University.
Visual Basic.NET BASICS Lesson 11 List Boxes, For Next Loops, and Label Settings.
Math 010 online work that was due today at the start of class: Section 1.3A Online Homework.
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.
PHY 107 – Programming For Science. Announcements no magic formulas exist  Need to learn concepts: no magic formulas exist  Single solution not useful;
CS123 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Spring 2011.
CSE 1340 Introduction to Computing Concepts Class 1 ~ Intro.
Chapter 7: Repetition Structure (Loop) Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills.
CS 121 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Winter, 2011 ©By the author. All rights reserved.
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.
CS122 Engineering Computation Lab Lab 3 Bruce Char Department of Computer Science Drexel University Winter 2010.
CS122 – Quiz 1 Winter, 2013 Quiz Hints. Quiz 1 Hints Question 1 – Understanding procs  First, we did not fully explain the structure of the Maple proc,
CS123 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Spring 2013.
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.
CS 121 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Fall 2011 ©By the author. All rights reserved. Permission.
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
CS190/295 Programming in Python for Life Sciences: Lecture 6
CS 121 Engineering Computation Lab Lab 3
Presentation transcript:

CS122 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Spring 2011

Review of Lab 1 Cycle Lab 1 – lab 1 and quiz 1 completed along with pre lab 2 quizlet –Quiz grades to be issued this week Major Lab 1 concepts to remember –Use of code edit regions to develop, test and debug scripts –Use of user defined functions to facilitate script development –Troubleshooting / debugging techniques (including Maple’s print functions)

Administrative Notes Please contact your individual instructors with questions and problems CLC (room 147 UC) will be staffed at same times as for cs121 in Winter (odd weeks)

Lab 2 Overview Based on materials from Chapter 12 and 13 readings –More practice with user defined functions We define them and then invoke them to draw things. We chain functions together to get more complicated drawings. –Using Maple tables (chapter 12) to store a collection of data How to initialize them How to get a program to enter values into a table How to use all the values you’ve put into a table, in a plot –Repetitive action “for” loops – chapter 13 Use an index variable to specify where an item is put in a table Use a loop to change variables repetitively. In order to do this successfully, the variables must be initialized in code executed before the loop starts.

Lab 2 Overview – Part 1 Part 1 – User defined functions that draw things –A, B, C. Develop a user defined function to draw a red box of any size. –D, E. Modify the function to be able to draw a box of any size and any location. Draw multiple boxes at once. Use the functions to draw three different pictures. Will be used in Lab 3 where we simulate a particle bouncing around in a box

Lab 2, Part 1 programming concepts Parameterized functions extend utility Do one thing (again) Do one of a class of things Chaining functions together “Building block” effect – each piece is small, combination is powerful Incremental design & testing

Lab 2 Overview – Part 2 Use a loop, and tables, to simulate a chemical reaction involving 4 chemicals –2.1 – Calculate the levels of the 4 chemicals as they change over time. Plot the levels of one of the chemicals as it changes over time. –2.2 – Extend the script of 2.1 to calculate and plot the levels of all 4 chemicals on the same graph.

Simulating Time Steps with Loops # Set up initial concentrations A := A0; B := B0; X := X0; Y := Y0; for i from 1 to numTimeSteps do newA := A - k1*A*X; … A := newA; indexTab[i] := i; Atab[i] := A; end do: display([Fplot(indexTab,Atab,"Green")], title="graph of A", labels=["time", "concentration"]);

Lab 2, Part 2 programming concepts It’s easy to see what code gets repeated: –What’s between the “for” and the “end do”. –Indentation helps readability. Pattern: Each repetition of the loop computes the level of a chemical at a particular time. Result: you compute the level of the chemicals at many different points in time. Use the index variable of the loop to place values in table(s).

Lab 2 programming concepts Pre loop processing –All the variables in the loop (except for the index variable) have to be initialized in a statement executed before the loop starts working. Post loop processing –Take all the value placed in the table, turn them into a list of values. –Plot the lists using plot as we’ve done before.

Lab 2 Maple Concepts: Observation on programming style Name user defined functions descriptively –Eg. Plot2lines versus P2 Use comments (#) within code edit regions to explain complex code or operations Indent statements within “for” loops –for i from 1 to 10 do statement 1 * statement n end do;

Lab 2 Maple Concepts: Part 0 Practice now with Maple features needed for this lab –The following concepts are illustrated Example 1 –Maple’s line plotting feature –User defined functions Example 2 –Code edit region –Maple’s table data structure and “for” loop feature –User defined functions

Course activities next week (4/25-4/29) Quiz 2 will be released on Friday (4/22) at 6 PM –Deadline: Wednesday (4/27) at 4:30 PM –Makeup quiz – from Thursday (4/28) at 9 AM through Sunday (5/1) at 11:00 PM 30% penalty Pre-lab 3 quizlet –From Thursday (4/28 – noon) through Monday (5/2 – 8 AM) Be sure to visit the CLC for quiz assistance