Lab 4: Structured Programming I

Size: px
Start display at page:

Download "Lab 4: Structured Programming I"

Transcription

1 4.1 Introduction Lab 4: Structured Programming I Lab this week is going to focus on selective structures and functions. 4.2 Resources The additional resources required for this assignment include: 0 Books: Punch & Enbody 0 Pratt Pundit Pages: Python:Logical Masks, Python:Plotting 0 Lab Manual Appendices: None 4.3 Getting Started 1. Log into one of the PCs in the lab using your NetId. Be sure it is set to log on to WIN. 2. In Windows: (a) Mount your CIFS drive. For instructions, start a browser and point it to: To Get Work Done Then click the link for File Access under Your Own Windows Computer. Note the comments on Pundit modifying what the OIT page instructions say. (b) Start a terminal with graphics. For instructions, point a browser to Check out the Using the PCs to Run Unix Programs Remotely section for how to get connected and make sure the connection is working. (c) Start Spyder. In the Windows menu, there is a group for Anaconda3; Spyder is in that group. If the PC asks for network permissions, click cancel. If the PC asks about updating, do not update. 3. In the terminal window (i.e. in UNIX; note the represents a space): (a) Change into your folder for EGR 103L, create a lab4 folder inside it, then switch into that folder: cd /EGR103 mkdir lab4 cd lab4 (b) Copy the tar file from Dr. G s space into your lab4 folder and expand the tar file: wget people.duke.edu/ mrg/egr103public/lab4files.tar tar -kxvf Lab4Files.tar (c) Make a personal copy of the lab report skeleton: cp -i Lab4Sample S19.tex lab4.tex 4 1

2 4.4 Ungraded You should look at, and if possible work on, 0 P&E Chapter 2 Exercises 1, 2, 5, 6, 7, 8, 9, 10, 11, 13, 14, 16 (very similar to hms), 17 (perfect square means square root is an integer), 20, 22 (heh heh), 24, 25, 26, 28, 35, and 40. For these ungraded problems, you can compare answers and processes with classmates. Do not share answers outside of those people currently taking the course. 4.5 Assignment Sinusoidal Functions A sinusoid is an oscillating function of some independent variable that can generally be written with three parameters - an amplitude, an angular frequency, and a phase shift. For purposes of this problem, the sinusoid you will be working with is a generic cosine: y(t A ω φ) = A cos (ωt + φ) where t is the independent variable, A is the amplitude, ω is the angular frequency in radians per second, and φ is the phase shift in radians. You should start by defining a function called y(t, A, omega, phi) that will return values based on the calculation above. Because you will eventually want the function to return an array of values, you will need to use NumPy s version of the cos function. Your goal is to examine how each of the parameters changes the sinusoid by putting four different sinusoids on one graph. Each will have its own line color and style as well as marker shape, edge color, and face color. You will need to include a legend. The following table gives all the details you need about each sinusoid: y(t A ω φ) line style line color marker marker edge marker face y(t 1 1 0) solid blue triangle up red magenta y(t 2 1 0) dashed yellow square red magenta y(t 1 2 0) dotted blue pentagon cyan magenta y(t 1 1 π/4) dash-dot blue hexagon (1) red green Graph the lines using 101 values between 2π and 2π. You already know the plot commands to make this part work. For the markers, you are going to tell the plot command to only mark every tenth data point; you can do this by putting markevery=10 in the plot command. There is information on the Python:Plotting page on Pundit about this. Furthermore, there are some other adjustments to be made: 0 Information on the different keyword arguments you need to make these adjustments is at: https :// matplotlib. org / api / _as_gen / matplotlib. pyplot. plot. html 0 The marker size will be The edge color and the face color will be different - to accomplish this, you can give one of the two colors in the format string and then assign the other using a keyword argument. For example, if you wanted black diamonds filled with cyan, and assuming you already created a set of axes called ax you could use either of the following two codes: ax. p l o t ( x, y, kd, m a r k e r f a c e c o l o r= c ) ax. p l o t ( x, y, cd, markeredgecolor= k ) Furthermore, as given on the HTML page referenced above, there are shortcut names such as: ax. p l o t ( x, y, kd, mfc= c ) The legend entries will be associated with the point styles and should look like y(t, 1, 1, 0) - note that you can get Spyder to put LaTeX-like symbols in legends by surrounding the appropriate LaTeX command with dollar signs. Your legend will likely end up being on top of part of your lines - that is fine for this week. You do not need labels or a title. In the body of the lab report, discuss how you think A, ω, and φ changed each curve. 4 2

3 4.5.2 Based on P&E 4.48 Instead of what is asked for in the problem, write a function called mult_table that takes up two two inputs - a number of rows and a number of columns to use in making a multiplication table. You may assume that the values given will be integers between 1 and 30 for each. The default values for each should be 12. The table should have a column header and row labels. Regardless of how many rows and columns, your program should leave two spaces for the row index and then four spaces for each value in the table. For example: In [ 1 ] : m u l t t a b l e ( 3, 7 ) will produce the following (where represents a space): When done, run the test_table.py script. This program will run three tests and produce outputs on the screen and then it will run the same three tests but will redirect the results to a text file. That text file should be imported to your lab document P&E 2.32 In addition to what is stated in the problem, assume that neither A nor C will be equal to 0. There is no requirement that A, B, or C be unique, however. There are more and less efficient ways of solving this problem. One quick thing to think about is the following: can you narrow down the possibilities for B in advance of writing the code? For each set of A and B values your program finds that work, your script should end by printing out a line such as: AB **2 is CAB but with your numbers in the place of the A, B, and C. For example, if your code (incorrectly) decided that A=7 and B=6 work, your code would print out: 76** 2 is 5776 You should indicate the values of A, B, and C in the body of your lab report. Note: the reason the example above does not work is that the resulting square is not a three-digit number as specified in the problem While it is possible for you to solve this without a computer - that is not the point. Your code needs to be written such that it scans through all - or a reasonable subset of - the possible combinations of A and B and checks to see which work P&E 2.38 You will be writing a function called digit_sum() which will take a single non-negative integer as an input and will return the single-digit sum described in the book. After thinking about how you the human would do this problem, you next need to think about how Python deals with numbers. One hint is that the // and % operations might come in very handy when thinking about how to isolate and all all the digits in a number together. One critical thing to note here is that the program may need to act recursively - that is, in cases where the result of adding all the digits together is still a number greater than 10, the function should then run on that new number. Try to get your function to first provide the initial sum of digits - for example, get to the point where digit_sum(827) returns 17. Then consider efficient ways to have to code continue calculating if need be or report out a value if done. There is a tester code to generate a diary of results - include those results in your lab report Based on Chapra Problem 3.10 This problem comes from Civil Engineering, and the methods used to solve it are used in classes taken by all engineers. It primarily relates to the Grand Challenge of restoring and improving urban infrastructure because it demonstrates a means of finding the amount of deflection experienced by a structural beam - something it is critical to understand before pursuing studies in this field. Though used on a beam in this problem, singularity functions show up at some point in every engineer s field of study. This problem is therefore an introduction to a mathematical and computational method that engineers have used to simplify the solution and analysis of many different problems - part of engineering the tools of scientific discovery. To solve this problem, you will use a function called Singularity to take an input array x, the shift value a, and the power n and return the result of the singularity function. 4 3

4 The function includes a logical mask - see the Pratt Pundit page for more information and for examples of logical masks. You can see how this function works with a linearly spaced array of points and several different values of the shift a and power n. The test_singularity.py code will be used to demonstrate this function. Note that for the lab you will not be including this example code or graph as a part of the document since it is purely an example - the graph and the code to make it are also on the shown below: Figure 4.1: Plots of y =< x a > n for different values of a and n 1 import numpy as np 2 import m a t p l o t l i b. pyplot as p l t 3 4 def s i n g u l a r i t y ( x, a, n ) : 5 return ( x > a ) 1 ( ( x a ) 1 1n ) 6 7 i f name == m a i n : 8 x = np. l i n s p a c e ( 2, 5, 500 ) 9 f i g, ax = p l t. s u b p l o t s (num=1 ) 10 f i g. c l f ( ) 11 f i g, ax = p l t. s u b p l o t s (num=1 ) ax. p l o t ( x, s i n g u l a r i t y ( x, 1, 0 ), k, 14 x, s i n g u l a r i t y ( x, 0, 1 ), r, 15 x, s i n g u l a r i t y ( x, 1, 1 ), g., 16 x, s i n g u l a r i t y ( x, 3, 2 ), b : ) 17 ax. legend ( l a b e l s =[ 2<x+1>ˆ02, 2<x>ˆ12, 18 2<x 1>ˆ12, 2<x 3>ˆ22 ], l o c= b est ) 19 ax. s e t t i t l e ( Four D i f f e r e n t Values o f 2y=<x a>ˆn2 ( NetID ) ) 20 ax. s e t x l a b e l ( x ) 21 ax. s e t y l a b e l ( y ) 22 ax. g r i d ( True ) 23 f i g. t i g h t l a y o u t ( ) 24 f i g. s a v e f i g ( S i n g P l o t s. eps ) 25 f i g. s a v e f i g ( S i n g P l o t s. pdf ) Table 4.1: test singularity.py code to generate graph in Figure

5 Next, write a script that uses the function to calculate the deflection u of a beam with nearly the same loading diagram in the book, except the torque being applied is 325 kip-ft instead of 150 kip-ft. This changes the equation to: u y x) = 5 6 x 0 4 x x x x x You will need to copy the singularity function from the test_singularity.py to your new code. Be sure that the plot has a proper title (with NetID) and axis labels. With respect to the original figure, a kip is equal to a kilo-pound, or 1000 lbs. 1 The x-axis of your plot will be measured in feet while the y-axis will not have units since units are not specified in the book. For the lab report, you must include your script which has all the code to analyze the beam, as well as the plot of the beam s deflection. In the body of the lab report, you will report what the maximum positive (up) and maximum negative (down) displacements are and approximately where along the beam those values can be found. Be sure to include units for the locations of the largest displacements; again, you will not need units for the displacements themselves since the book does not provide them. You should use 100 points for the x coordinates of the plot and 10 6 points to determine and locate the extreme displacements. For information on how (and why) to do this, see the Pratt Pundit page on Python:Plotting, specifically the section called Using Different Scales. less. As opposed to Kip, who is the Electrical and Computer Engineering Department Laboratory Manager and weighs significantly 4 5

Lab 5: Program Control and Functions

Lab 5: Program Control and Functions EGR 53L - Spring 2010 Lab 5: Program Control and Functions 5.1 Introduction Lab this week is going to focus on structured programming, specifically using logic and selective structures to control program

More information

Lab 5: Structured Programming II

Lab 5: Structured Programming II 5.1 Introduction Lab 5: Structured Programming II Lab this week is going to focus on debugging, list comprehensions, and loading data from files. 5.2 Resources The additional resources required for this

More information

Lab 6: Graphical Methods

Lab 6: Graphical Methods Lab 6: Graphical Methods 6.1 Introduction EGR 53L - Fall 2009 Lab this week is going to introduce graphical solution and presentation techniques as well as surface plots. 6.2 Resources The additional resources

More information

Skills Quiz - Python Edition Solutions

Skills Quiz - Python Edition Solutions 'XNH8QLYHUVLW\ (GPXQG73UDWW-U6FKRRORI(QJLQHHULQJ EGR 103L Fall 2017 Skills Quiz - Python Edition Solutions Michael R. Gustafson II Name (please print): NetID (please print): In keeping with the Community

More information

Introduction to Matlab to Accompany Linear Algebra. Douglas Hundley Department of Mathematics and Statistics Whitman College

Introduction to Matlab to Accompany Linear Algebra. Douglas Hundley Department of Mathematics and Statistics Whitman College Introduction to Matlab to Accompany Linear Algebra Douglas Hundley Department of Mathematics and Statistics Whitman College August 27, 2018 2 Contents 1 Getting Started 5 1.1 Before We Begin........................................

More information

PyPlot. The plotting library must be imported, and we will assume in these examples an import statement similar to those for numpy and math as

PyPlot. The plotting library must be imported, and we will assume in these examples an import statement similar to those for numpy and math as Geog 271 Geographic Data Analysis Fall 2015 PyPlot Graphicscanbeproducedin Pythonviaavarietyofpackages. We willuseapythonplotting package that is part of MatPlotLib, for which documentation can be found

More information

Introduction to Matlab

Introduction to Matlab What is Matlab? Introduction to Matlab Matlab is software written by a company called The Mathworks (mathworks.com), and was first created in 1984 to be a nice front end to the numerical routines created

More information

PART 1 PROGRAMMING WITH MATHLAB

PART 1 PROGRAMMING WITH MATHLAB PART 1 PROGRAMMING WITH MATHLAB Presenter: Dr. Zalilah Sharer 2018 School of Chemical and Energy Engineering Universiti Teknologi Malaysia 23 September 2018 Programming with MATHLAB MATLAB Environment

More information

Getting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text

Getting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text Chapter 1 Getting Started How to Get Matlab Matlab physically resides on each of the computers in the Olin Hall labs. See your instructor if you need an account on these machines. If you are going to go

More information

1 Introduction to Matlab

1 Introduction to Matlab 1 Introduction to Matlab 1. What is Matlab? Matlab is a computer program designed to do mathematics. You might think of it as a super-calculator. That is, once Matlab has been started, you can enter computations,

More information

PyPlot. The plotting library must be imported, and we will assume in these examples an import statement similar to those for numpy and math as

PyPlot. The plotting library must be imported, and we will assume in these examples an import statement similar to those for numpy and math as Geog 271 Geographic Data Analysis Fall 2017 PyPlot Graphicscanbeproducedin Pythonviaavarietyofpackages. We willuseapythonplotting package that is part of MatPlotLib, for which documentation can be found

More information

MATLAB Introduction to MATLAB Programming

MATLAB Introduction to MATLAB Programming MATLAB Introduction to MATLAB Programming MATLAB Scripts So far we have typed all the commands in the Command Window which were executed when we hit Enter. Although every MATLAB command can be executed

More information

AMS 27L LAB #2 Winter 2009

AMS 27L LAB #2 Winter 2009 AMS 27L LAB #2 Winter 2009 Plots and Matrix Algebra in MATLAB Objectives: 1. To practice basic display methods 2. To learn how to program loops 3. To learn how to write m-files 1 Vectors Matlab handles

More information

Bi 1x Spring 2014: Plotting and linear regression

Bi 1x Spring 2014: Plotting and linear regression Bi 1x Spring 2014: Plotting and linear regression In this tutorial, we will learn some basics of how to plot experimental data. We will also learn how to perform linear regressions to get parameter estimates.

More information

Basic Beginners Introduction to plotting in Python

Basic Beginners Introduction to plotting in Python Basic Beginners Introduction to plotting in Python Sarah Blyth July 23, 2009 1 Introduction Welcome to a very short introduction on getting started with plotting in Python! I would highly recommend that

More information

Introduction to Excel Workshop

Introduction to Excel Workshop Introduction to Excel Workshop Empirical Reasoning Center June 6, 2016 1 Important Terminology 1. Rows are identified by numbers. 2. Columns are identified by letters. 3. Cells are identified by the row-column

More information

LAB 2: DATA FILTERING AND NOISE REDUCTION

LAB 2: DATA FILTERING AND NOISE REDUCTION NAME: LAB TIME: LAB 2: DATA FILTERING AND NOISE REDUCTION In this exercise, you will use Microsoft Excel to generate several synthetic data sets based on a simplified model of daily high temperatures in

More information

MAT 275 Laboratory 1 Introduction to MATLAB

MAT 275 Laboratory 1 Introduction to MATLAB MATLAB sessions: Laboratory 1 1 MAT 275 Laboratory 1 Introduction to MATLAB MATLAB is a computer software commonly used in both education and industry to solve a wide range of problems. This Laboratory

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab What is Matlab The software program called Matlab (short for MATrix LABoratory) is arguably the world standard for engineering- mainly because of its ability to do very quick prototyping.

More information

MATLAB SUMMARY FOR MATH2070/2970

MATLAB SUMMARY FOR MATH2070/2970 MATLAB SUMMARY FOR MATH2070/2970 DUNCAN SUTHERLAND 1. Introduction The following is inted as a guide containing all relevant Matlab commands and concepts for MATH2070 and 2970. All code fragments should

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab November 22, 2013 Contents 1 Introduction to Matlab 1 1.1 What is Matlab.................................. 1 1.2 Matlab versus Maple............................... 2 1.3 Getting

More information

Matlab Tutorial 1: Working with variables, arrays, and plotting

Matlab Tutorial 1: Working with variables, arrays, and plotting Matlab Tutorial 1: Working with variables, arrays, and plotting Setting up Matlab First of all, let's make sure we all have the same layout of the different windows in Matlab. Go to Home Layout Default.

More information

Python lab session 1

Python lab session 1 Python lab session 1 Dr Ben Dudson, Department of Physics, University of York 28th January 2011 Python labs Before we can start using Python, first make sure: ˆ You can log into a computer using your username

More information

Computer Programming in MATLAB

Computer Programming in MATLAB Computer Programming in MATLAB Prof. Dr. İrfan KAYMAZ Engineering Faculty Department of Mechanical Engineering Arrays in MATLAB; Vectors and Matrices Graphing Vector Generation Before graphing plots in

More information

Class #15: Experiment Introduction to Matlab

Class #15: Experiment Introduction to Matlab Class #15: Experiment Introduction to Matlab Purpose: The objective of this experiment is to begin to use Matlab in our analysis of signals, circuits, etc. Background: Before doing this experiment, students

More information

fplot Syntax Description Examples Plot Symbolic Expression Plot symbolic expression or function fplot(f) fplot(f,[xmin xmax])

fplot Syntax Description Examples Plot Symbolic Expression Plot symbolic expression or function fplot(f) fplot(f,[xmin xmax]) fplot Plot symbolic expression or function Syntax fplot(f) fplot(f,[xmin xmax]) fplot(xt,yt) fplot(xt,yt,[tmin tmax]) fplot(,linespec) fplot(,name,value) fplot(ax, ) fp = fplot( ) Description fplot(f)

More information

Mechanical Engineering Department Second Year (2015)

Mechanical Engineering Department Second Year (2015) Lecture 7: Graphs Basic Plotting MATLAB has extensive facilities for displaying vectors and matrices as graphs, as well as annotating and printing these graphs. This section describes a few of the most

More information

LAB 2: DATA FILTERING AND NOISE REDUCTION

LAB 2: DATA FILTERING AND NOISE REDUCTION NAME: LAB SECTION: LAB 2: DATA FILTERING AND NOISE REDUCTION In this exercise, you will use Microsoft Excel to generate several synthetic data sets based on a simplified model of daily high temperatures

More information

Lab 12: Numerical Differentiation and Integration

Lab 12: Numerical Differentiation and Integration EGR 53L - Spring 2010 Lab 12: Numerical Differentiation and Integration 12.1 Introduction This lab is aimed at calculating derivatives and integrals of discrete data in MATLAB. At the end of the lab, you

More information

Excel Spreadsheets and Graphs

Excel Spreadsheets and Graphs Excel Spreadsheets and Graphs Spreadsheets are useful for making tables and graphs and for doing repeated calculations on a set of data. A blank spreadsheet consists of a number of cells (just blank spaces

More information

MATLAB Tutorial III Variables, Files, Advanced Plotting

MATLAB Tutorial III Variables, Files, Advanced Plotting MATLAB Tutorial III Variables, Files, Advanced Plotting A. Dealing with Variables (Arrays and Matrices) Here's a short tutorial on working with variables, taken from the book, Getting Started in Matlab.

More information

Three-Dimensional (Surface) Plots

Three-Dimensional (Surface) Plots Three-Dimensional (Surface) Plots Creating a Data Array 3-Dimensional plots (surface plots) are often useful for visualizing the behavior of functions and identifying important mathematical/physical features

More information

ME30_Lab1_18JUL18. August 29, ME 30 Lab 1 - Introduction to Anaconda, JupyterLab, and Python

ME30_Lab1_18JUL18. August 29, ME 30 Lab 1 - Introduction to Anaconda, JupyterLab, and Python ME30_Lab1_18JUL18 August 29, 2018 1 ME 30 Lab 1 - Introduction to Anaconda, JupyterLab, and Python ME 30 ReDev Team 2018-07-18 Description and Summary: This lab introduces Anaconda, JupyterLab, and Python.

More information

EE 216 Experiment 1. MATLAB Structure and Use

EE 216 Experiment 1. MATLAB Structure and Use EE216:Exp1-1 EE 216 Experiment 1 MATLAB Structure and Use This first laboratory experiment is an introduction to the use of MATLAB. The basic computer-user interfaces, data entry techniques, operations,

More information

Additional Plot Types and Plot Formatting

Additional Plot Types and Plot Formatting Additional Plot Types and Plot Formatting The xy plot is the most commonly used plot type in MAT- LAB Engineers frequently plot either a measured or calculated dependent variable, say y, versus an independent

More information

ECE 3793 Matlab Project 1

ECE 3793 Matlab Project 1 ECE 3793 Matlab Project 1 Spring 2017 Dr. Havlicek DUE: 02/04/2017, 11:59 PM Introduction: You will need to use Matlab to complete this assignment. So the first thing you need to do is figure out how you

More information

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window.

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window. EE 350L: Signals and Transforms Lab Spring 2007 Lab #1 - Introduction to MATLAB Lab Handout Matlab Software: Matlab will be the analytical tool used in the signals lab. The laboratory has network licenses

More information

Introduction to Python and NumPy I

Introduction to Python and NumPy I Introduction to Python and NumPy I This tutorial is continued in part two: Introduction to Python and NumPy II Table of contents Overview Launching Canopy Getting started in Python Getting help Python

More information

Purpose of the lecture MATLAB MATLAB

Purpose of the lecture MATLAB MATLAB Purpose of the lecture MATLAB Harri Saarnisaari, Part of Simulations and Tools for Telecommunication Course This lecture contains a short introduction to the MATLAB For further details see other sources

More information

4. Use of complex numbers in deriving a solution to an LTI ODE with sinusoidal signal, and getting from such an expression to amplitude and phase lag

4. Use of complex numbers in deriving a solution to an LTI ODE with sinusoidal signal, and getting from such an expression to amplitude and phase lag Learning objectives Phase Line: 1. Interpretation of the phase line: critical points, stable vs unstable, and filling in nonconstant solutions. Horizontal translation carries solutions to other solutions.

More information

Section Graphs of the Sine and Cosine Functions

Section Graphs of the Sine and Cosine Functions Section 5. - Graphs of the Sine and Cosine Functions In this section, we will graph the basic sine function and the basic cosine function and then graph other sine and cosine functions using transformations.

More information

MATH STUDENT BOOK. 12th Grade Unit 4

MATH STUDENT BOOK. 12th Grade Unit 4 MATH STUDENT BOOK th Grade Unit Unit GRAPHING AND INVERSE FUNCTIONS MATH 0 GRAPHING AND INVERSE FUNCTIONS INTRODUCTION. GRAPHING 5 GRAPHING AND AMPLITUDE 5 PERIOD AND FREQUENCY VERTICAL AND HORIZONTAL

More information

How to Make Graphs with Excel 2007

How to Make Graphs with Excel 2007 Appendix A How to Make Graphs with Excel 2007 A.1 Introduction This is a quick-and-dirty tutorial to teach you the basics of graph creation and formatting in Microsoft Excel. Many of the tasks that you

More information

Chapter 2 (Part 2) MATLAB Basics. dr.dcd.h CS 101 /SJC 5th Edition 1

Chapter 2 (Part 2) MATLAB Basics. dr.dcd.h CS 101 /SJC 5th Edition 1 Chapter 2 (Part 2) MATLAB Basics dr.dcd.h CS 101 /SJC 5th Edition 1 Display Format In the command window, integers are always displayed as integers Characters are always displayed as strings Other values

More information

MS6021 Scientific Computing. TOPICS: Python BASICS, INTRO to PYTHON for Scientific Computing

MS6021 Scientific Computing. TOPICS: Python BASICS, INTRO to PYTHON for Scientific Computing MS6021 Scientific Computing TOPICS: Python BASICS, INTRO to PYTHON for Scientific Computing Preliminary Notes on Python (v MatLab + other languages) When you enter Spyder (available on installing Anaconda),

More information

Lesson 5.2: Transformations of Sinusoidal Functions (Sine and Cosine)

Lesson 5.2: Transformations of Sinusoidal Functions (Sine and Cosine) Lesson 5.2: Transformations of Sinusoidal Functions (Sine and Cosine) Reflections Horizontal Translation (c) Vertical Translation (d) Remember: vertical stretch horizontal stretch 1 Part A: Reflections

More information

1. Register an account on: using your Oxford address

1. Register an account on:   using your Oxford  address 1P10a MATLAB 1.1 Introduction MATLAB stands for Matrix Laboratories. It is a tool that provides a graphical interface for numerical and symbolic computation along with a number of data analysis, simulation

More information

Euler s Method with Python

Euler s Method with Python Euler s Method with Python Intro. to Differential Equations October 23, 2017 1 Euler s Method with Python 1.1 Euler s Method We first recall Euler s method for numerically approximating the solution of

More information

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment

What is MATLAB? What is MATLAB? Programming Environment MATLAB PROGRAMMING. Stands for MATrix LABoratory. A programming environment What is MATLAB? MATLAB PROGRAMMING Stands for MATrix LABoratory A software built around vectors and matrices A great tool for numerical computation of mathematical problems, such as Calculus Has powerful

More information

Applications. segment CD. 1. Find the area of every square that can be drawn by connecting dots on a 3 dot-by-3 dot grid.

Applications. segment CD. 1. Find the area of every square that can be drawn by connecting dots on a 3 dot-by-3 dot grid. Applications. Find the area of every square that can be drawn by connecting dots on a 3 dot-by-3 dot grid.. On dot paper, draw a hexagon with an area of 6 square units. 3. On dot paper, draw a square with

More information

Week Two. Arrays, packages, and writing programs

Week Two. Arrays, packages, and writing programs Week Two Arrays, packages, and writing programs Review UNIX is the OS/environment in which we work We store files in directories, and we can use commands in the terminal to navigate around, make and delete

More information

MAT 003 Brian Killough s Instructor Notes Saint Leo University

MAT 003 Brian Killough s Instructor Notes Saint Leo University MAT 003 Brian Killough s Instructor Notes Saint Leo University Success in online courses requires self-motivation and discipline. It is anticipated that students will read the textbook and complete sample

More information

Using the Matplotlib Library in Python 3

Using the Matplotlib Library in Python 3 Using the Matplotlib Library in Python 3 Matplotlib is a Python 2D plotting library that produces publication-quality figures in a variety of hardcopy formats and interactive environments across platforms.

More information

DSP Laboratory (EELE 4110) Lab#1 Introduction to Matlab

DSP Laboratory (EELE 4110) Lab#1 Introduction to Matlab Islamic University of Gaza Faculty of Engineering Electrical Engineering Department 2012 DSP Laboratory (EELE 4110) Lab#1 Introduction to Matlab Goals for this Lab Assignment: In this lab we would have

More information

Middle School Summer Review Packet for Abbott and Orchard Lake Middle School Grade 7

Middle School Summer Review Packet for Abbott and Orchard Lake Middle School Grade 7 Middle School Summer Review Packet for Abbott and Orchard Lake Middle School Grade 7 Page 1 6/3/2014 Area and Perimeter of Polygons Area is the number of square units in a flat region. The formulas to

More information

Middle School Summer Review Packet for Abbott and Orchard Lake Middle School Grade 7

Middle School Summer Review Packet for Abbott and Orchard Lake Middle School Grade 7 Middle School Summer Review Packet for Abbott and Orchard Lake Middle School Grade 7 Page 1 6/3/2014 Area and Perimeter of Polygons Area is the number of square units in a flat region. The formulas to

More information

Test 1 - Python Edition

Test 1 - Python Edition 'XNH8QLYHUVLW\ (GPXQG73UDWW-U6FKRRORI(QJLQHHULQJ EGR 103L Spring 2018 Test 1 - Python Edition Shaundra B. Daily & Michael R. Gustafson II NetID (please print): In keeping with the Community Standard, I

More information

Section 4.4: Parabolas

Section 4.4: Parabolas Objective: Graph parabolas using the vertex, x-intercepts, and y-intercept. Just as the graph of a linear equation y mx b can be drawn, the graph of a quadratic equation y ax bx c can be drawn. The graph

More information

Contents 10. Graphs of Trigonometric Functions

Contents 10. Graphs of Trigonometric Functions Contents 10. Graphs of Trigonometric Functions 2 10.2 Sine and Cosine Curves: Horizontal and Vertical Displacement...... 2 Example 10.15............................... 2 10.3 Composite Sine and Cosine

More information

This module aims to introduce Precalculus high school students to the basic capabilities of Matlab by using functions. Matlab will be used in

This module aims to introduce Precalculus high school students to the basic capabilities of Matlab by using functions. Matlab will be used in This module aims to introduce Precalculus high school students to the basic capabilities of Matlab by using functions. Matlab will be used in subsequent modules to help to teach research related concepts

More information

Vertical and Horizontal Translations

Vertical and Horizontal Translations SECTION 4.3 Vertical and Horizontal Translations Copyright Cengage Learning. All rights reserved. Learning Objectives 1 2 3 4 Find the vertical translation of a sine or cosine function. Find the horizontal

More information

Chapter 3: Introduction to MATLAB Programming (4 th ed.)

Chapter 3: Introduction to MATLAB Programming (4 th ed.) Chapter 3: Introduction to MATLAB Programming (4 th ed.) Algorithms MATLAB scripts Input / Output o disp versus fprintf Graphs Read and write variables (.mat files) User-defined Functions o Definition

More information

Math12 Pre-Calc Review - Trig

Math12 Pre-Calc Review - Trig Math1 Pre-Calc Review - Trig Multiple Choice Identify the choice that best completes the statement or answers the question. 1. Which of the following angles, in degrees, is coterminal with, but not equal

More information

UNIVERSITETET I OSLO

UNIVERSITETET I OSLO (Continued on page 2.) UNIVERSITETET I OSLO Det matematisk-naturvitenskapelige fakultet Examination in: INF1100 Introduction to programming with scientific applications Day of examination: Friday, December

More information

Logical Subscripting: This kind of subscripting can be done in one step by specifying the logical operation as the subscripting expression.

Logical Subscripting: This kind of subscripting can be done in one step by specifying the logical operation as the subscripting expression. What is the answer? >> Logical Subscripting: This kind of subscripting can be done in one step by specifying the logical operation as the subscripting expression. The finite(x)is true for all finite numerical

More information

+. n is the function parameter and the function returns the sum.

+. n is the function parameter and the function returns the sum. CS/INFO 1305 Programming Exercise 2 Due Wednesday, July 22, at 10pm Submit either Level 1 or Level 2. For Level 2, problem 2.3 is required; complete ONE of 2.1 and 2.2. 1 Level 1 1. During the previous

More information

Classes 7-8 (4 hours). Graphics in Matlab.

Classes 7-8 (4 hours). Graphics in Matlab. Classes 7-8 (4 hours). Graphics in Matlab. Graphics objects are displayed in a special window that opens with the command figure. At the same time, multiple windows can be opened, each one assigned a number.

More information

2. Periodic functions have a repeating pattern called a cycle. Some examples from real-life that have repeating patterns might include:

2. Periodic functions have a repeating pattern called a cycle. Some examples from real-life that have repeating patterns might include: GRADE 2 APPLIED SINUSOIDAL FUNCTIONS CLASS NOTES Introduction. To date we have studied several functions : Function linear General Equation y = mx + b Graph; Diagram Usage; Occurence quadratic y =ax 2

More information

Reference and Style Guide for Microsoft Excel

Reference and Style Guide for Microsoft Excel Reference and Style Guide for Microsoft Excel TABLE OF CONTENTS Getting Acquainted 2 Basic Excel Features 2 Writing Cell Equations Relative and Absolute Addresses 3 Selecting Cells Highlighting, Moving

More information

EGR 111 Functions and Relational Operators

EGR 111 Functions and Relational Operators EGR 111 Functions and Relational Operators This lab is an introduction to writing your own MATLAB functions. The lab also introduces relational operators and logical operators which allows MATLAB to compare

More information

Lab1: Use of Word and Excel

Lab1: Use of Word and Excel Dr. Fritz Wilhelm; physics 230 Lab1: Use of Word and Excel Page 1 of 9 Lab partners: Download this page onto your computer. Also download the template file which you can use whenever you start your lab

More information

(Ca...

(Ca... 1 of 8 9/7/18, 1:59 PM Getting started with 228 computational exercises Many physics problems lend themselves to solution methods that are best implemented (or essentially can only be implemented) with

More information

SUM - This says to add together cells F28 through F35. Notice that it will show your result is

SUM - This says to add together cells F28 through F35. Notice that it will show your result is COUNTA - The COUNTA function will examine a set of cells and tell you how many cells are not empty. In this example, Excel analyzed 19 cells and found that only 18 were not empty. COUNTBLANK - The COUNTBLANK

More information

MATHEMATICA LAB SKILLS ACTIVITY 2: ANALYZING DATA IN MATHEMATICA

MATHEMATICA LAB SKILLS ACTIVITY 2: ANALYZING DATA IN MATHEMATICA MATHEMATICA LAB SKILLS ACTIVITY 2: ANALYZING DATA IN MATHEMATICA LEARNING GOALS You will be 1. able to define and use functions in Mathematica. 2. able to scale and shift lists (arrays) of data. 3. able

More information

Chemistry Excel. Microsoft 2007

Chemistry Excel. Microsoft 2007 Chemistry Excel Microsoft 2007 This workshop is designed to show you several functionalities of Microsoft Excel 2007 and particularly how it applies to your chemistry course. In this workshop, you will

More information

Introduction to Excel Workshop

Introduction to Excel Workshop Introduction to Excel Workshop Empirical Reasoning Center September 9, 2016 1 Important Terminology 1. Rows are identified by numbers. 2. Columns are identified by letters. 3. Cells are identified by the

More information

User-Defined Function

User-Defined Function ENGR 102-213 (Socolofsky) Week 11 Python scripts In the lecture this week, we are continuing to learn powerful things that can be done with userdefined functions. In several of the examples, we consider

More information

EGR 111 Functions and Relational Operators

EGR 111 Functions and Relational Operators EGR 111 Functions and Relational Operators This lab is an introduction to writing your own MATLAB functions. The lab also introduces relational operators and logical operators which allows MATLAB to compare

More information

Control Flow: Loop Statements

Control Flow: Loop Statements Control Flow: Loop Statements A loop repeatedly executes a of sub-statements, called the loop body. Python provides two kinds of loop statements: a for-loop and a while-loop. This exercise gives you practice

More information

G r a d e 1 0 I n t r o d u c t i o n t o A p p l i e d a n d P r e - C a l c u l u s M a t h e m a t i c s ( 2 0 S )

G r a d e 1 0 I n t r o d u c t i o n t o A p p l i e d a n d P r e - C a l c u l u s M a t h e m a t i c s ( 2 0 S ) G r a d e 0 I n t r o d u c t i o n t o A p p l i e d a n d P r e - C a l c u l u s M a t h e m a t i c s ( 0 S ) Midterm Practice Exam Answer Key G r a d e 0 I n t r o d u c t i o n t o A p p l i e d

More information

NAVIGATING UNIX. Other useful commands, with more extensive documentation, are

NAVIGATING UNIX. Other useful commands, with more extensive documentation, are 1 NAVIGATING UNIX Most scientific computing is done on a Unix based system, whether a Linux distribution such as Ubuntu, or OSX on a Mac. The terminal is the application that you will use to talk to the

More information

: Intro Programming for Scientists and Engineers Assignment 1: Turtle Graphics

: Intro Programming for Scientists and Engineers Assignment 1: Turtle Graphics Assignment 1: Turtle Graphics Page 1 600.112: Intro Programming for Scientists and Engineers Assignment 1: Turtle Graphics Peter H. Fröhlich phf@cs.jhu.edu Joanne Selinski joanne@cs.jhu.edu Due Date: Wednesdays

More information

Department of Chemical Engineering ChE-101: Approaches to Chemical Engineering Problem Solving MATLAB Tutorial Vb

Department of Chemical Engineering ChE-101: Approaches to Chemical Engineering Problem Solving MATLAB Tutorial Vb Department of Chemical Engineering ChE-101: Approaches to Chemical Engineering Problem Solving MATLAB Tutorial Vb Making Plots with Matlab (last updated 5/29/05 by GGB) Objectives: These tutorials are

More information

This assignment is due the first day of school. Name:

This assignment is due the first day of school. Name: This assignment will help you to prepare for Geometry A by reviewing some of the topics you learned in Algebra 1. This assignment is due the first day of school. You will receive homework grades for completion

More information

2nd Year Computational Physics Week 1 (experienced): Series, sequences & matrices

2nd Year Computational Physics Week 1 (experienced): Series, sequences & matrices 2nd Year Computational Physics Week 1 (experienced): Series, sequences & matrices 1 Last compiled September 28, 2017 2 Contents 1 Introduction 5 2 Prelab Questions 6 3 Quick check of your skills 9 3.1

More information

Computational Modelling 102 (Scientific Programming) Tutorials

Computational Modelling 102 (Scientific Programming) Tutorials COMO 102 : Scientific Programming, Tutorials 2003 1 Computational Modelling 102 (Scientific Programming) Tutorials Dr J. D. Enlow Last modified August 18, 2003. Contents Tutorial 1 : Introduction 3 Tutorial

More information

Excel R Tips. is used for multiplication. + is used for addition. is used for subtraction. / is used for division

Excel R Tips. is used for multiplication. + is used for addition. is used for subtraction. / is used for division Excel R Tips EXCEL TIP 1: INPUTTING FORMULAS To input a formula in Excel, click on the cell you want to place your formula in, and begin your formula with an equals sign (=). There are several functions

More information

ENGR (Socolofsky) Week 07 Python scripts

ENGR (Socolofsky) Week 07 Python scripts ENGR 102-213 (Socolofsky) Week 07 Python scripts A couple programming examples for this week are embedded in the lecture notes for Week 7. We repeat these here as brief examples of typical array-like operations

More information

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER BENC 2113 DENC ECADD 2532 ECADD LAB SESSION 6/7 LAB

More information

UNIVERSITETET I OSLO

UNIVERSITETET I OSLO (Continued on page 2.) UNIVERSITETET I OSLO Det matematisk-naturvitenskapelige fakultet Examination in: INF1100 Introduction to programming with scientific applications Day of examination: Thursday, October

More information

QUICK INTRODUCTION TO MATLAB PART I

QUICK INTRODUCTION TO MATLAB PART I QUICK INTRODUCTION TO MATLAB PART I Department of Mathematics University of Colorado at Colorado Springs General Remarks This worksheet is designed for use with MATLAB version 6.5 or later. Once you have

More information

PROGRAMMING WITH MATLAB WEEK 6

PROGRAMMING WITH MATLAB WEEK 6 PROGRAMMING WITH MATLAB WEEK 6 Plot: Syntax: plot(x, y, r.- ) Color Marker Linestyle The line color, marker style and line style can be changed by adding a string argument. to select and delete lines

More information

Introduction to Scientific Computing

Introduction to Scientific Computing Introduction to Scientific Computing Dr Hanno Rein Last updated: October 12, 2018 1 Computers A computer is a machine which can perform a set of calculations. The purpose of this course is to give you

More information

CSC 110 Final Exam. ID checked

CSC 110 Final Exam. ID checked ID checked CSC 110 Final Exam Name: Date: 1. Write a Python program that asks the user for a positive integer n and prints out n evenly spaced values between 0 and 10. The values should be printed with

More information

Activity: page 1/10 Introduction to Excel. Getting Started

Activity: page 1/10 Introduction to Excel. Getting Started Activity: page 1/10 Introduction to Excel Excel is a computer spreadsheet program. Spreadsheets are convenient to use for entering and analyzing data. Although Excel has many capabilities for analyzing

More information

CHAPTER 6. The Normal Probability Distribution

CHAPTER 6. The Normal Probability Distribution The Normal Probability Distribution CHAPTER 6 The normal probability distribution is the most widely used distribution in statistics as many statistical procedures are built around it. The central limit

More information

1-- Pre-Lab The Pre-Lab this first week is short and straightforward. Make sure that you read through the information below prior to coming to lab.

1-- Pre-Lab The Pre-Lab this first week is short and straightforward. Make sure that you read through the information below prior to coming to lab. EELE 477 Lab 1: Introduction to MATLAB Pre-Lab and Warm-Up: You should read the Pre-Lab and Warm-up sections of this lab assignment and go over all exercises in the Pre-Lab section before attending your

More information

EE 301 Signals & Systems I MATLAB Tutorial with Questions

EE 301 Signals & Systems I MATLAB Tutorial with Questions EE 301 Signals & Systems I MATLAB Tutorial with Questions Under the content of the course EE-301, this semester, some MATLAB questions will be assigned in addition to the usual theoretical questions. This

More information

Mark Scheme (Results) Summer Pearson Edexcel GCSE In Mathematics B (2MB01) Higher (Calculator) Unit 3

Mark Scheme (Results) Summer Pearson Edexcel GCSE In Mathematics B (2MB01) Higher (Calculator) Unit 3 Mark Scheme (Results) Summer 015 Pearson Edexcel GCSE In Mathematics B (MB01) Higher (Calculator) Unit 3 Edexcel and BTEC Qualifications Edexcel and BTEC qualifications are awarded by Pearson, the UK s

More information

EE3TP4: Signals and Systems Lab 1: Introduction to Matlab Tim Davidson Ext Objective. Report. Introduction to Matlab

EE3TP4: Signals and Systems Lab 1: Introduction to Matlab Tim Davidson Ext Objective. Report. Introduction to Matlab EE3TP4: Signals and Systems Lab 1: Introduction to Matlab Tim Davidson Ext. 27352 davidson@mcmaster.ca Objective To help you familiarize yourselves with Matlab as a computation and visualization tool in

More information