3 Pages

lec06_long

Course: CSCI 0040, Fall 2009
School: Sanford-Brown Institute
Rating:
 
 
 
 
 

Word Count: 1654

Document Preview

to Introduction Scientific Computing and Problem Solving Lecture #6 Plotting CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.0 Announcements Assignments Review lecture slides Study examples and corresponding M-files Work on your own examples! Get help when needed! TA hours Ask questions if some concepts are not well understood! Please always check the course web page...

Register Now

Unformatted Document Excerpt

Coursehero >> Georgia >> Sanford-Brown Institute >> CSCI 0040

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
to Introduction Scientific Computing and Problem Solving Lecture #6 Plotting CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.0 Announcements Assignments Review lecture slides Study examples and corresponding M-files Work on your own examples! Get help when needed! TA hours Ask questions if some concepts are not well understood! Please always check the course web page Announcements, updated documents, lecture materials No labs but regular TA hours over Long Weekend! :) lab3 = []; TA_hours_during_long_weekend = true; HW#2 due on Thu 2:30pm Now 11:59pm! CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.1 Where we are First two weeks MATLAB programming environment arrays and operations logical type, flow control and selection This lecture HW2 clarifications Conditionals revisited through examples Plotting capabilities with MATLAB Examples - applications CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.2 Data types So far: double, char, logical They determine the type of data stored at variables Some more to come Built-in conversion functions Often: source of errors How much memory space is used How data is represented What types of operations can be applied to data E.g., num2str, str2num, int2str, char, double E.g., assignments of inconsistent data types 2009 - 6.3 CSCI0040 - Introduction to Scientific Computing and Problem Solving Motion of a Projectile Laws of motion describing the trajectory of an object with initial velocity of v0 m/s at an angle of ! Appears in two of the problems of HW#2 CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.4 Motion of a Projectile (cont.) Initial velocity v0 has horizontal and vertical components v0 x = v0 cos ! and v0 y = v0 sin ! Vertical motion is governed by 1 v y = v0 y ! gt and y = v0 y t ! gt 2 2 Highest point is reached when t hmax = v0 y g and hmax = v 2 0y 2g 2009 - 6.5 CSCI0040 - Introduction to Scientific Computing and Problem Solving Motion of a Projectile (cont.) Total flying time: solve for y = 0 2v0 y 1 2 y = v0 y t ! gt = 0 or ttot = = 2t hmax 2 g Horizontal velocity is constant and position is x = v0 x t CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.6 Linear indices m " n array Elements are stored in column major order One-dimension alternative indexing A=[0 2 3;4 5 0]; A(5) is equal to A(1,3)=3 Some functions use linear indices Referencing to elements of arrays according to their column major order E.g., find(A) returns column vector [2 3 4 5] CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.7 Example 5-1 Analysis of Temperature Data The U.S. National Oceanic and Atmospheric Administration (NOAA) reports the daily maximum temperatures for Washington, D.C. in April 2002 were: 58 73 73 53 50 48 56 73 73 66 69 63 74 82 84 91 93 89 91 80 59 69 56 64 63 66 64 74 63 69 Find Number of days the temperature was above 75 Number of days the temperature was between 65 and 80 Days of the month the temperature was between 50 and 60 m-files: Ex5_1 CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.8 If-end ...| ...| MATLAB commands ...| if conditional expression ...| ...| MATLAB commands ...| end ...| ...| MATLAB commands ...| False if True Commands m-files: Ex5_2 CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.9 If-else-end ...| ...| MATLAB commands ...| if conditional expression ...| ...| Group 1 commands ...| else ...| ...| Group 2 commands ...| end ...| ...| MATLAB commands ...| 2009 - 6.10 False if True Commands Group 2 Commands Group 1 CSCI0040 - Introduction to Scientific Computing and Problem Solving Example 5-3 Water Level in a Tower A water tower has a cylindrical base and upper section that is an inverted frustum cone Write a script that calculates the volume of water in the tank given the water level height h provided by the user Water height h has two components, hcyl and hcone 2 Vcyl = ! rcyl hcyl Vcone = where ! hcone 2 (r1 + r1r2 + r22 ) 3 10.5 hcone 14 r1 = rcyl and r2 = rh = r1 + m-files: Ex5_3 2009 - 6.11 CSCI0040 - Introduction to Scientific Computing and Problem Solving If-elseif-else-end False if True False elseif True Commands Group 3 Commands Group 2 Commands Group 1 ...| ...| MATLAB commands ...| if conditional expression ...| ...| Group 1 commands ...| elseif conditional expression ...| ...| Group 2 commands ...| else ...| ...| Group 3 commands ...| end ...| ...| MATLAB commands ...| In general: elseif can appear 0 or more times and else at most once) Nesting is possible: conditional statements are commands themselves! CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.12 switch Expression is scalar or string Many cases can be included Statements associated with first matching case are executed If no matches, otherwise group is executed At most one group (block) is executed Each case may include more than one value to test matching: {valueA, valueB} switch switch expression case value1 ...| ...| Group 1 commands ...| case value2 ...| ...| Group 2 commands ...| case value3 ...| ...| Group 3 commands ...| otherwise ...| ...| Group 4 commands ...| m-files: lect5_12 end 2009 - 6.13 CSCI0040 - Introduction to Scientific Computing and Problem Solving Visualizing Data CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.14 plot Command plot(x,y) where x and y are vectors with same number of elements plot(x,y,'line specifiers', 'PropertyName', PropertyValue) Line Specifiers Style: solid, dashed, dotted, dash-dot Color: red, green, blue, cyan, Marker: etc. plus, circle, asterisk, point, square, etc. doc plot m-files: lect6_1 2009 - 6.15 CSCI0040 - Introduction to Scientific Computing and Problem Solving plot Command (cont.) plot(x,y,'line specifiers', 'PropertyName', PropertyValue) Property Name and Value LineWidth MarkerSize MarkerEdgeColor MarkerFaceColor doc plot m-files: lect6_2 CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.16 Plotting Functions plot command Create vector of values using function Plot it y = 3.5"0.5 x cos(6 x) for " 2 ! x ! 4 Copy Figure in Edit menu m-files: lect6_3 CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.17 Plotting Functions fplot command fplot('function','limits','line specifiers') Function typed as a string using any letter as the independent variable '8*x^2+5*cos(x)' '8*t^2+5*cos(t)' Can't include any previously defined variables. Limits is a vector [xmin, xmax] or [xmin, xmax, ymin, ymax] Example y = x 2 + 4 sin( 2 x) " 1 for " 3 ! x ! 3 CSCI0040 - Introduction to Scientific Computing and Problem Solving m-files: lect6_3 2009 - 6.18 Multiple Graphs Using plot command If x, y, u, v, t, h are pairs of vectors of equal length plot(x,y,u,v,t,h) A function and its first and second derivatives. A derivate describes how a function changes as its dependent variable changes (e.g., position, velocity, acceleration) y = 3 x 3 " 26 x + 10 Example y! = 9 x 2 " 26 y!! = 18 x CSCI0040 - Introduction to Scientific Computing and Problem Solving m-files: lect6_4 2009 - 6.19 Multiple Plots (cont.) hold command Plot first graph Type hold on Plot additional graphs Type hold off line command Like plot command but adds graphs to existing plot line(x,y,'PropertyName',PropertyValue) Use plot first then line commands m-files: lect6_5, lect6_6 CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.20 Formatting Plots Labels xlabel('horizontal axis text') ylabel('vertical axis text') Title title('title text') General text text(x, y,'text to go at (x,y)') CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.21 Formatting Plots (cont.) Legends legend('label1', 'label2',,pos) where pos specifies location (see Help) Text formatting Style: bold, italic, fonts Subscripts and superscripts Greek characters Color CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.22 Formatting Plots (cont.) Axis formatting axis([xmin, xmax, ymin, ymax]) axis equal axis square axis tight Grid grid on grid off Plot Editor CSCI0040 - Introduction to Scientific Computing and Problem Solving m-files: lect6_7 2009 - 6.23 Logarithmic Plots Present data over a wide range of values semilogy(x, y) log (base 10) for y semilogx(x, y) log (base 10) for x loglog(x, y) log (base 10) for both Line specifiers and Property Names can be applied y=2 ( "0.2 x +10 ) for 0.1 ! x ! 60 m-files: lect6_8 2009 - 6.24 CSCI0040 - Introduction to Scientific Computing and Problem Solving Error Bars in Plots Shows scatter or uncertainty in data Vertical line attached to data point Can extend equally above and below the point or be asymmetric errorbar(x, y, e) e is vector of error values errorbar(x, y, u, l) u, l are vectors of upper and lower error bounds m-files: lect6_9 CSCI0040 - Introduction to Scientific Computing and Problem Solving 2009 - 6.25 Special Plots ...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Sanford-Brown Institute - CSCI - 0040
Introduction to Scientific Computing and Problem SolvingLecture #6 PlottingCSCI0040 - Introduction to Scientific Computing and Problem Solving2009 - 6.0Announcements Assignments Review lecture slides Study examples and corresponding M-files
Sanford-Brown Institute - CSCI - 0040
Introduction to Scientific Computing and Problem SolvingLecture #8 Functions II & IterationCSCI0040 - Introduction to Scientific Computing and Problem Solving2009 - 8.0Announcements [Announcements of the day] By now, youve completed HW#3
Michigan - APR - 04
THEUNIVERSITY OF MICHIGAN REGENTS COMMUNICATION ACTION REQ~T~:Art and Architecture Building 1 st and 2nd Floor Renovations~ ~eguested ;SJackgroundApproval to Proceed with ProjectI The Taubman College of Architecture and Urban Planning pro
Michigan - APR - 07
Michigan - JUN - 07
Michigan - MAR - 02
Michigan - JUN - 04
Michigan - JUNE - 01
Michigan - OCT - 02
Michigan - JUN - 05
Michigan - DEC - 04
Michigan - APR - 05
Michigan - JUL - 02
Michigan - NOV - 04
Michigan - NOV - 03
THE UNIVERSITY OF MICHIGAN REGENTS COMMUNICATIONACTION REQUESTSubject: Action Reguested: Ba2kground:AnnStreetParkingStructureApproval ofProject and Authorization to Appoint an Architect / EngineerIn July 200 I, the Regents approved the
Michigan - JUL - 04
Michigan - NOV - 03
THE UNIVERSITY OF MICHIGAN REGENTS COMMUNICATIONACTION REQUESTSubjectAthletic Department Academic SuccessCenter~ Reguested:Approval of Schematic DesignBackground:At the March 2003 meeting, the Regents approved the Academic Success Center
Michigan - APR - 03
THE UNIVERSITY OF MICHIGAN REGENTS COMMUNICATIONACTION REQUESTSubject:College of Engineering Computer Science and Engineering BuildingAction ReQuested:Approval of Schematic DesignBackground:At the October 2002 meeting, the Regents approv
Michigan - JUL - 03
THE UNIVERSITY OF MICHIGAN REGENTS COMMUNICATIONACTION REQUESTSubject:University of Michigan Hospitals and Health Centers (UMllliC) Depression Center and Ambulatory Psychiatry New Facility and Infrastructure ImprovementsAction Reguested: Backg
Sanford-Brown Institute - OLD - 00
December 10 - December 16, 2000 THE BOSTON AREA PHYSICS CALENDARThe Boston Area Physics Calendar is published weekly during the academicyear by the Center for Theoretical Physics at MIT. You may send yourannouncement by e-mail (bapc@lns.m
Michigan - ISSUE - 2
The Effects of a Recent Zebra Mussel Invasion on the Phytoplankton Community in Lake Leelanau in Northern Michigan Erika L. ShanklandMentor: Dr. Rex L. LoweAbstractThe discovery of zebra mussels was made in 1998 in Lake St. Clair, Michigan. Thro
Sanford-Brown Institute - JAVA - 3
The Stack ADT (4.2) StacksThe Stack ADT stores arbitrary objects Insertions and deletions follow the last-in first-out scheme Think of a spring-loaded plate dispenser Main stack operations:push(object): inserts an element object pop(): removes and
Michigan - WAR - 5
*Saturday, November 18, 1995*AND WHERE WERE YOU ON THE NIGHT IN QUESTION, MS. REMENCUS?by Laura B. WaskeyTime: Early morningPlace: The RavenCousin Laura looked around the shambles of The Raven. The plan had worked,and it was all because of C
Michigan - WAR - 5
*Tuesday, November 7, 1995*A PARTY PLANNED (Part 1b)by Cousin Toniwith a lot of help from Sara Orel and Partly KTime: DawnPlace: Toronto International AirportSara pushed her honey colored hair out of her face again as she shepherdedyet anot
Michigan - WAR - 5
*Thursday, November 2, 1995*TOUCHDOWN IN TORONTOby Laura B. WaskeyTime: MidnightPlace: TorontoAs the pilot of the Air Canada flight announced that they would be landingin Toronto in ten minutes, Cousin Laura breathed a sigh of relief. She wa
Michigan - WAR - 5
*Sunday, November 5, 1995*LADIES OF THE KNIGHTby Perri SmithTime: DawnPlace: Nick's loftNick opened the door to the loft quietly, trying not to wake theKnighties. They'd had a long couple of days, and deserved all the sleepthey could get. A
Michigan - WAR - 5
*Friday, October 27, 1995*THE BILL COLLECTOR ALWAYS RINGS TWICE (a)Or: The Birth of a Mercby Elizabeth Ann LewisPlace: Elizabeth's home"Hi, Mom." Elizabeth dropped her laundry off by the washing machine andbegan sorting through her week's a
Michigan - WAR - 5
*Wednesday, November 8, 1995*ONWARD AND UPWARD (Part 2)Or: Godiva!(tm) Did Someone Say Godiva?by Cousin Cherri MunozTime: 1am ESTPlace: The Raven A nervous-looking businessman approached the guard at the entrance of theRaven. "Uh.Uh."
Michigan - WAR - 5
*Sunday, November 12, 1995*TORREY IN TECHNO TORMENT.by Sherri CampbellTime: Late afternoonPlace: Vachon's churchTorrey leaned back purring in contentment. It was *so* nice to be able tokick back and relax. The last few days the Vaqueros ha
Michigan - WAR - 5
*Thursday, November 9, 1995*DOWN AND OUTby Cousin CandiceTime: A tad past midnightPlace: The RavenCandice was on her way out the door of LaCroix's apartment when a loud<Mrrrouwlll> stoped her and a small furry thing wrapped itself around her
Michigan - WAR - 5
WAR V QUOTE LIST--"CHESS-OPENING MOVES" "Did we say trouble? I don't remember anyone saying 'trouble,' do you?"-"CHESS-OPENING MOVES: LOFTY EXPECTATIONS" "Pinky, are you pondering what I'm pondering?" "I think so, Brain, but where are we g
Michigan - WAR - 5
*Friday, November 17, 1995*A LITTLE CATCHING UP (b)by Toni C. HolmPlace: Mercenary HeadquartersThe Merc answered the buzz from the front door to see on the video screena bald man and a woman with that sort of frumpy "federal bureaucrat" look
Michigan - WAR - 5
*Friday, November 3, 1995*BREAKING AND ENTERINGby Vicki Jean MerrimanTime: 2:15am ESTPlace: The RavenVicki watched Deborah and LaCroix leave the car and head to the Raven. Shehad changed out of the silver grey double breasted suit into somet
Sanford-Brown Institute - EC - 111
Constant Returns to Scale f (x1 , x2 ) = f (x1 , x2 )1 1 2 2 y = x1 x2y5 3.75 2.5 2.5 1.25 1.25 1.25 2.5 3.75 5 x1 3.75 5x20In the 45 degee line:y53.752.51.250 0 1.25 2.5 3.75 x 51Isoquants: (for y=1, y=2 and y=3)y 107.5
Sanford-Brown Institute - EC - 111
Name_Economics 111: Intermediate Microeconomics Spring 2005 Practice Midterm 1 Anwer KeyYou have 1 hour and 20 minutes. Only clarifying questions are allowed. Do not cheat. Do not panic. Enjoy the exam. (The actual exam will be a little shorter t
Sanford-Brown Institute - BN - 168
1ExercisesChapter 11. Generate spikes for 10 s (or longer if you want better statistics) using a Poisson spike generator with a constant rate of 100 Hz, and record their times of occurrence. Compute the coefcient of variation of the interspike in
Sanford-Brown Institute - CSCI - 1260
CS126: Introduction to CompilersAssignment 8: ICODEOut: 10/31/03 Due: 11/14/031.0 IntroductionThe next step in your compiler involves taking the fully resolved abstract syntax trees you have been working hard to achieve and translate them into a
Sanford-Brown Institute - CSCI - 0310
MIPSCS31 Pascal Van HentenryckCS031Lecture 131MIPSA real assembly language Basic architecture ALU operations Memory operations Branch I/O Control StructuresCS031Lecture 132MIPS ArchitectureUsed in several commercial workstat
Sanford-Brown Institute - CS - 159
CSCI 1590 Intro to Computational ComplexityHardness of ApproximationEric RachlinBrown UniversityMay 2, 2008Eric Rachlin (Brown University)CSCI 1590 Intro to Computational ComplexityMay 2, 20081/8Summary1Inapproximability for CLIQU
Sanford-Brown Institute - CS - 159
CSCI 1590 Intro to Computational ComplexityHardness of ApproximationEric RachlinBrown UniversityApril 30, 2008Eric Rachlin (Brown University)CSCI 1590 Intro to Computational ComplexityApril 30, 20081/8PCPpc ,ps [q(n), r (n)]Denition
Sanford-Brown Institute - CSCI - 2580
Uncapacitated Warehouse Location Problem Find the number and locations of sites where a distributor should open warehouses to minimize its distribution cost to the stores & #Facility LocationPascal Van Hentenryck Solution Of interestmin$ '
Sanford-Brown Institute - CS - 159
CSCI 1590 Intro to Computational ComplexityPCP and NP Eric RachlinBrown UniversityApril 25, 2008Eric Rachlin (Brown University)CSCI 1590 Intro to Computational ComplexityApril 25, 20081 / 10Summary1PCP2PCP and NP3Gap Introdu
Michigan - MATH - 116
Final Review ProblemsMath 116, Section 36 November 26, 2008(~<1 Evaluate the following integrals.<C4 1Ctt(a)J~1 - 4x 2-~V1.1 ~ ~l,~M.i;JAfflII I Z la / 0'0 )dx~2.\11' "IlAt\~ (~) + C(b)J1 J9 _ 4x 2 dx=\.2->
Michigan - MATH - 116
Quiz #8: CumulativeMATH 116, Section 36 November 19, 2008Please answer all questions completely including relevant units. You have 30 minutes.1. (5 points) Find the Taylor series for sin x about x = O. Write with sigma notation. (If you have th
Michigan - MATH - 116
Quiz #9: CUll1ulativeMATH 116, Section 36 November 24, 2008Please answer all questions completely including relevant units. You have 20 minutes.1. (3 points each) Decide if the following statements are TRUE or FALSE. Include a brief explanatio
Michigan - MATH - 116
Quiz #2: 6.1, 6.2, 6.4, 7.1MATH 116, Section 36 September 15, 2008Please answer all questions completely including relevant units. You have 25 minutes.1. (3 points each) Please mark the following TRUE or FALSE. Provide a short explanation. (a) I
Michigan - MATH - 116
Coppin - MATH - 132
COPPIN STATE UNIVERSITY Department of Mathematics and Computer Science 2500 W. North Avenue Baltimore, Maryland 21216-3698COURSE SYLLABUS for PRECALCULUSMATH 1324 CREDITSReview of the equations and graphs of algebraic, exponential, and logarit
Coppin - COSC - 199
This file is called sillytext.txt.It just has a few lines.The lines are mostly boring.There are some letters that this file does not have.
Indiana South Bend - WIMAN - 2008
CALL FOR PAPERSInternational Workshop on Wireless Mesh and Ad Hoc Networks (WiMAN08)http:/www.cs.iusb.edu/~liqzhang/WiMAN2008/index.htmIn conjunction with IEEE ICDCS 2008Beijing, China, June 20, 2008 Organizing CommitteeProgram Co-chairsChris
Indiana South Bend - C - 201
Learning Objectives Structures Structure types Pointers and structure types Structures as function argumentsCopyright 2006 Pearson Addison-Wesley. All rights reserved.6-1Structures Aggregate data type: struct Aggregate meaning "grouping"
Indiana South Bend - C - 201
C201: Linked List1Learning Objectives Nodes and Linked Lists Operations on Linked List Insert Search Remove2Nodes and Linked Lists Why do we need linked list? Linked list Simple example of "dynamic data structure" Composed of nodes
Chester - ECO - 338
IHT Article Print Page Copyright 2001 The International Herald Tribune | www.iht.com Economic Whiplash: Slump Has No Borders Joseph Kahn and Edmund L. Andrews New York Times Service
Chester - ECO - 338
FT.com / World bank & IMF 2002 annual meeting Thursday Sep 26 2002. All times are London time. Subscribe to FT.com Username Password Subscribe now To explore ou
Indiana South Bend - C - 201
4bread197230102.50apples4120202000.25coat321942579.99advil32891305.75
Indiana South Bend - WIMAN - 2008
- The Second IEEE International Workshop on Wireless Mesh and Ad Hoc Networks (WiMAN'08) Beijing, China, June 20, 2008 in conjunction with ICDCS 200
Indiana South Bend - C - 201
1 5 7 3 40 54 88 78 0 -222 4 6 9 6 10 100 201 657 77-9 9 8 8 3 45 9 7 34 81
Michigan State University - CSE - 331
Algorithm Theory Summary The algorithm as a solution to a problem Some algorithms are more efficient than others complexity theory. Some problems are harder than others. Some problems have NO efficient algorithms to solve them. Some proble
Indiana South Bend - C - 201
1 9905 303
Indiana South Bend - C - 490
To: [unknown], INTERNET:c490f849@cs.iusb.eduFrom: "Josh D. Tenenberg", INTERNET:josh@cs.iusb.eduDate: 9/27/99, 5:37 PMRe: Java: CLASSPATH on linux All, A student asked about how to compile things on linux, since they weregetting an e
Indiana South Bend - C - 335
Getting Started with spim1Getting Started with spimThe simple version of SPIM is called spim on Windows and UNIX. It can be run from any console or by another program. Although spim may be more difficult to learn, it operates just like PCSpim an