Upload
diane-sanders
View
216
Download
0
Tags:
Embed Size (px)
Citation preview
CS 121 Engineering Computation Lab Lab 4
Department of Computer ScienceDrexel University
Summer 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.
Your class instructor and TA
• Instructor for this section: Office: Email: Telephone:
• Your TAs are: Note that verification sheet requires you to put
down instructor’s name.
Upcoming Activities
• This Week (Week 4)• Quiz 4 (Tuesday – Friday)
• Next Week (Week 5)• Lab 5 on Monday (7/20)• Proficiency Exam on Wednesday (7/22)• Instructions for Proficiency Exam
• Sent later this week.• Via e-mail and Wednesday recitation
Lab 4
• Part 1 Multiplotting – Problem 1.1
• Part 2 Import Data – Problem 2.1
• Part 3 Piece wise functions – Problem 2.2
• Part 4 Maps – Problem 2.3
Multiplotting
• Basically means plotting more than one graph in a plotConsider 2 functions – x^2,x^3
• Chapter 6 – Section 6.3• Syntax – plot(set of expr,var=range, color=list of colors)• How do we plot it for the above 2 functions
plot({x^2,x^3},x=0..10}
The functions in plot can also be user defined functions. Part 1.1 of the lab requires this.
Multiplotting (cont)
• Coloring Multi plotsAutomatically colors are chosen.
• How to plot with specified Color ?We do this by changing the parameter of Plot
Plot({f(n),g(n)},x=0..100,color=[“red”, “green”, “blue”])
Demo of Import Data (Text) Instructors can use the following slides optionally.
grades := ImportMatrix(‘GradeData1.csv’,source=csv)
gradeList := convert(grades,list)
OR
ImportData()
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 Mainlist
Part 3 : Piecewise Function
What is Piecewise Function?– It is a function whose definition is dependent on the
value of the independent variable.
Part 3 : Piecewise Function
• Piecewise functions are defined using the common functional notation, where the body of the function is an array of functions and associated sub domains.
Part 3 : Piecewise Function• Maple Notation for a piecewise function
• Use the curly braces from Expressions
• Use Ctrl + Shift + R to add new row to the function
Part 4 : Maps
• A function that associates a single output to each input element drawn from a fixed set such as the real numbers
• In our case the fixed set is a List – Problem 2.2 and Problem 2.3
• Use map for element-wise application of a function
Finishing up – save your work
• Save worksheets onto the Desktop. You can call them Lab4Part1, Lab3Part4, etc. Or you could put all the work into one worksheet and just call it Lab 4.
• 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.
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.