CS 121 Engineering Computation Lab Lab 3

Slides:



Advertisements
Similar presentations
CS122 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Winter 2010.
Advertisements

Lab 8 – C# Programming Adding two numbers CSCI 6303 – Principles of I.T. Dr. Abraham Fall 2012.
CS123 Engineering Computation Lab Lab 2 Bruce Char Department of Computer Science Drexel University Spring 2010.
CS105 Lab 1 – Introduction Section: ??? TA: ??? ??? Announcements CITES Accounts Compass Netfiles Other Administrative Information CS105 Fall
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 121 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University January 5-9, 2009 ©By the author. All rights reserved.
CS161 Topic #21 CS161 Introduction to Computer Science Topic #2.
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 123 Computational Lab IIl Spring 2008 Department of Computer Science Drexel University Copyright by the authors. Permission is given for students and.
Math 15 Lecture 10 University of California, Merced Scilab Programming – No. 1.
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.
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.
CS 121 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Summer, 2009 ©By the author. All rights reserved.
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.
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 2 Bruce Char Department of Computer Science Drexel University Spring 2011.
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.
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.
CS 123 Computational Lab IIl Spring 2008 Department of Computer Science Drexel University Copyright by the authors. Permission is given for students and.
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.
1 Project 7: Looping. Project 7 For this project you will produce two Java programs. The requirements for each program will be described separately on.
CS 121 Engineering Computation Lab Lab 1 Bruce Char Department of Computer Science Drexel University Winter, 2011 ©By the author. All rights reserved.
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.
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.
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.
Physics 114: Lecture 1 Overview of Class Intro to MATLAB
CMPT 201 Computer Science II for Engineers
Applied Discrete Mathematics Week 2: Functions and Sequences
CS122 Engineering Computation Lab Lab 4
CS 121 Engineering Computation Lab Lab 5
CS 121 Engineering Computation Lab Lab 3
CS 121 Engineering Computation Lab Lab 2
CS123 Engineering Computation Lab Lab 4
Standard Operating Procedure
Adding a File to a Course
CSE1320 INTERMEDIATE PROGRAMMING
Week 1 Gates Introduction to Information Technology cosc 010 Week 1 Gates
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
CS122 Engineering Computation Lab Lab 3
Lecture 1: Introduction
CS 139 – Programming Fundamentals
First Python Program Professor Hugh C. Lauer CS-1004 — Introduction to Programming for Non-Majors (Slides include materials from Python Programming: An.
Blackboard Tutorial (Student)
CSCI N317 Computation for Scientific Applications Unit 1 – 1 MATLAB
CSCI N207 Data Analysis Using Spreadsheet
Experiment No. (1) - an introduction to MATLAB
Running a Java Program using Blue Jay.
MA Fall Instructor: Tim Rolling -Office: MATH 719 -
Presentation transcript:

CS 121 Engineering Computation Lab Lab 3 Department of Computer Science Drexel University February 2-6, 2009 ©By the author. All rights reserved. Permission is given to CS121 Fall 2008 staff and students to use and reproduce these notes for their own use. 1 1 1

Your class instructor and TA Instructor for this section: Tim Cheeseman Office: UC 147 (CLC) Email: tcheeseman@drexel.edu Your TAs are: 061 – Cem Sahin, Lloyd Ricks 561 – Pat Lockner Note that verification sheet requires you to put down instructor’s name. 2 2 2

Week 3 and 4 retrospective Lab 2: fourth week Limited Precision Arithmetic Data structure, functions Quiz 2: fourth week Getting stuck on problems during the quizzes? Use the Cyber Learning Center (UC147)‏ Use the discussion board for short questions 3 3 3

Lab 3 Overview Part 1 Scripts (ch. 4 readings)‏ Assignments (function)‏ Part 2 User defined functions Part 3 Lists, sets and sequences Operations Random Number generation Reading in data from an external file. 4 4 4

Assignments Assignments are of the form name := expression where a is a variable and n can be an expression Name can be a single letter (upper-/lower- case sensitive), or a combination of a letter followed by letters and numbers and underscores. A a a1 expr L eqn1 my_grade largestScore Some names are reserved by Maple and cannot be used as something to assign to: Pi for I end quit 5 5 5

Demo of Assignments p := x^2 x^2 p p - 1=0 x ^ 2-1 = 0 unassign(‘p’) p does not stand for “x^2” any more. 6 6 6 6

Scripts What is a script? How are scripts useful? A script is a sequence of operations. Usually, the later operations use the results of the earlier ones. Labels or assignments are used to make the references convenient. How are scripts useful? Scripts are useful when you expect to solve a series of similar problems. Reuse: cut, paste, edit, re-execute. 7 7 7

Pointers on Script Use Rather than use the clickable interface, it's better to lay out the operations textually one line at a time. You can create a script using only clickable operations if you don't need to change the operations that are specified by pop-up menu. Use assignments and labels to refer to results of previous steps. Place "editable quantities" as assignments at the beginning of the script, rather than scattering the editing task all over the script ("I forget, what do I need to change?") 8 8 8

Demo of Script Use Demo the sheep problem. Compared to the script given in section 4.5, we’re replacing the clickable operations with the function version of the solve, eval, and plot operations. This solves the problem for sheepEqn :=N = 220/(1+10*.83^t) popSize := 80 Copy region Edit sheepEqn := N = 330/(1+10*.79^t); popSize := 85; Re-execute edited region 9 9 9

User Defined Functions Maple users can define new functions That is one of the key features that makes Maple less like a calculator and more like a programming language 10 10 10

How to define your own function Through the clickable interface The general form is from the f:=a->y in the Expression palette User-defined function textually function name:= input name-> expression involving inputs The ( ....) - > .....defines the function. The function name := gives the function a name 11 11 11

Usage of User Defined Functions Format: function name (values for inputs)‏ Example: f := (x) -> sqrt(x) + 1 f(9) evaluates to 4 as a result. Example: g := (a, b) -> (a+b)/2 g(3.5, 6.5) evaluates to 5 as a result. 12 12 12

Demo of User Defined Functions Define three functions t, s and p t := n -> 1/n*sin(n*Pi*x); s(m) = the sum of t(i) s := m -> sum(t(2^i), i=1..m); p(m) = produces a plot of s(m) for x between 0 and 4 p := m -> plot(s(m), x=0..4) Here is one example of its use: p(1); 13 13 13

Demo of sequences, lists, sets Maple demo of: Assignment Use of indexing to get at pieces Concatenation of sequences Sequences as "inside" of function invocation: binomial(3,5); versus s := 1,2; binomial(s); Convert sequence to list: [s] Convert sequence to set: {s} Convert list to sequence: op(L) Convert set to sequence: op(S) nops(...) gives number of elements sort(list) sorts in ascending order; sort(list, `>`) descending 14 14 14

Script test data in Problem 1.2 Problem 1.2 asks you to generate a list of random numbers to test your scripts on. Just follow the directions, entering the instructions as listed. You should see a list of random numbers which you can apply your script to. Don't worry about the random number generator's operating principles yet. This lab, we just want you to use the generator. 15 15 15

Script Data for Problem 3.1 Detailed procedures are in the lab direction Importing GradeData1 and GradeData2 Where are the two files? Course website -> lab materials Bb Vista -> Lab Exercises -> Import Data 16

Finishing up – save your work Save worksheets onto the Desktop. You can call them Lab3Part1, Lab3Part2, etc. Or you could put all the work into one worksheet and just call it Lab 3. Submit a copy to Blackboard site as evidence that you did the lab. Email a copy to yourself and/or your lab partners as an attachment so you can look at what you did for review purposes later. We will use this week's work in the next Lab. 17 17 17

Turn in your verification sheet Make sure your name/user id/section number/ date,time/instructor name are on the verification sheet. Get the verification sheet signed for all parts you completed and hand it in. 18 18 18

Weeks 5 and 6 Take Quiz 3 Monday-Friday Week 6 October 27-31 Maple TA server down for maintenance 9- 10am and briefly at 3pm each day during the week. Greater penalty if you take the “late version” of quiz. 19 19 19

Demo of RandomTools Instructors can use the following slides optionally. > > 20

Demo of Import Data Instructors can use the following slides optionally. 21

Demo of Import Data (cont’d)‏ 22

Demo of Import Data (cont’d)‏ 23

Demo of Import Data (cont’d)‏ Right Click on the Blue Matrix. Click Assign to a name. The name used here is ‘thelist’ Convert the matrix to a list using Mainlist := convert(thelist,list)‏ Perform the required operations on the list 24