Introduction to Python and NumPy I

Size: px
Start display at page:

Download "Introduction to Python and NumPy I"

Transcription

1 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 variables Data types Matrix math with NumPy More fun (?) with matrices Plotting in more detail Adding text labels to plots Changing the axes Creating script.py files Exercises Exercise 1 - Fun with matrices Exercise 2 - Plotting everything but the kitchen sinc (?) Exercise 3 - "Decoding" other people's Python code Purpose This tutorial will introduce you to Python, NumPy and plotting with Matplotlib. It is based on a MATLAB tutorial provided by Prof. Todd Ehlers at the University of Tübingen, Germany. This is the first half of the tutorial, which is continued in part two. Overview In this laboratory exercise you will be introduced to using the Python computer language and some helpful Python libraries for math and plotting. As mentioned in lecture, I've chosen to use the Python instead of MATLAB for this course, mainly because Python is free and open source, and will work just as well as MATLAB in many instances. Python is an easy to learn, powerful programming language that is widely used and very flexible. It is an interpreted language, meaning you'll be able to enter commands at a prompt and the computer will execute the commands when you press the Enter key. This makes testing code and learning efficient and easy. Python can be run from the command line on Linux- or Macbased computers, but we will be using the Enthought Canopy software instead. Canopy comes pre-configured with many different scientific and mathematical libraries, as well as the ability to easily make plots, edit scripts and make good use of Python. As a student, you can make an account on the Enthought website and download a free copy of the academic version of Canopy. It is pre-installed on all of the machines in D211, but you may find it helpful to have a personal copy for use outside of class. It is easy to install and should work without much effort. Below are instructions for launching Canopy on the computers in room D211, followed by a series of tutorial tasks to get you familiar with Python and the numerical libraries included in NumPy. Launching Canopy To get started, you will need to launch and configure the Enghought Canopy software package.

2 1. Start by opening a Terminal window by clicking on the Dash Home icon at the top left corner of the screen and entering "terminal" into the search box. Click on the Terminal icon. After Terminal opens, you might want to right-click on the icon and select 'Lock to Launcher' 2. You can launch Canopy by entering the text /usr/local/canopy/canopy into the Terminal window. We can make an alias to make it easier to launch Canopy in the future by typing echo "alias Canopy=/usr/local/Canopy/canopy" >> ~/.bashrc in a terminal window. Thus, Canopy can be launched from the Terminal by simply typing Canopy. 3. If this is the first time you have run Canopy, you will be prompted to configure your Canopy environment. When the prompt appears, click Continue.

3 4. Configuration can take up to 15 minutes. After the configuration completes, select No when asked whether Canopy should be your default Python environment, then click Start using Canopy.

4 5. The main Canopy window should now appear, as shown below. Click on the Editor button to get started. 6. You should now see the Canopy editor window. The window has three panels. Along the left side is a file browser. The upper panel on the right side is a text editor panel, which will allow you to create, modify and save Python source code. The lower panel is an interactive Python environment (IPython), where you can enter commands that will be processed by the Python interpreter and the results will be displayed. At this point, you're ready to get started learning a bit of Python! In the future, you can launch Canopy by typing /usr/local /Canopy/canopy in a Terminal window. Getting started in Python With the Canopy editor window open, we can now start tinkering. To get started, we'll look at an example of how to quickly make a plot, then review what has actually happened with the Python command. >>> plot([1,2,3,4,5],'o-')

5 I will be using the generic command prompt text >>> to refer to the Python command prompt. In Canopy, the prompt is in the format In [ n ]:, where n in the number of the command in the list of commands that have been run in the current Canopy session. If you copy and past the command above (excluding the prompt text ' >>> '), you should see the following plot when you press Enter. So, what happened? Well, a few things. First, we've used the plot function to produce a plot of the numbers in the list [1,2,3,4,5] as a function of their index value, or position in the list. The plot function can be used to produce 2D data plots in Canopy. The values enclosed in the brackets [ ] comprise a Python list. Python lists can contain any kind of data stored in a common structure, in this case a list of whole numbers, or integers. The index value refers to the position in the list, starting from 0. For example, the value 3 in the list is located at index value 2, whereas list value 5 is at index value 4. So what about the 'o-' after the comma? In this case, we've told the plot command to use circle symbols ( o) and a solid line (-) to plot the data. If this isn't 100% clear at this point, don't worry. The plot command used above is actually part of the Matplotlib Python library. Matplotlib is automatically loaded in Enthought Canopy, making it easy to quickly generate plots. Getting help There are several ways to get help in Python. Personally, I typically go to Google and enter the command or issue for which I'm seeking help. Python is widely used, and thus a Google search can often be the most efficient way to find information. Within Python itself, there are also some very convenient ways to get help. The most obvious is the help function. To get started, you can type >>> help() This will bring up a general help browser, in which you can look up functions, keywords or other Python topics. To get help on specific functions, you can enter the function name with the help function. For example, to get help on the plot function, you can type >>> help(plot) Many Python functions also have documentation strings that can be used for help. To output the doc string for the plot function, you could type

6 >>> print(plot. doc ) In case it is unclear above, the doc string associated with a function is given by adding a period, two underscores, the text 'doc' and two more underscores (. doc ). Python variables As we have seen in lectures, variables in Python are quite flexible and can be used to reference many different kinds of data. Let's say we wanted to add a few numbers together. >>> # Add two numbers 4 # Their sum is reported >>> _ + 5 # Add 5 to the previous sum 9 # 9, as expected As we can see above, Python makes a decent calculator. One important feature to notice is that in interactive Python sessions, the most recently returned value is stored in the Python variable _ (an underscore). You can use this shortcut, for example to add to the previous sum, as shown. Also note that I've included some comments at the ends of the lines to describe what is going on. Recall that comments start with the # character and the text that follows does not get executed by Python. Now let's calculate a sum and assign it to a variable. >>> x = # Store the value of as the variable x >>> x 4 >>> x = x # Add 2.5 to the previous x value >>> x 6.5 >>> y = 2**2 + math.log(math.pi) * math.sin(x) # A slightly more complicated example >>> y >>> theta = math.acos(-1) # Note trigonometry is done in radians >>> theta In these cases, we've stumbled upon something new, the Python math library. Many common math functions (sine, cosine, logarithms, etc.) are contained in the math library, as well as certain math constants like pi. Functions in the math library can be accessed by including math. before the name of the function. Thus, to get the sine value of variable x you type math.sin(x). You can find the functions that are contained within a Python library in Canopy by typing the library name followed by a period and then hitting the Tab key. I suggest you give this a shot for the math library.

7 Data types Among the many convenient features of Python is dynamic data typing. To understand this, we first need to see what data types are by way of some examples. >>> var1 = "Text" >>> var2 = 1 >>> var3 = 4.94 >>> var4 = True As you can see above, we've assigned different types of data to four different variables. The first variable, var1, contains text, while variables 2 and 3, var2 and var3, contain numbers, and variable 4, var4, is a boolean variable ( True or False). These differences are important because some types of data can or cannot interact with one another. For example, you would have no problem if you tried to calculate var2/var3, but Python would give you an error message if you tried to divide var1 by var3. Python doesn't know how to divide text by a number. Feel free to try this if you don't believe me. You can use the type function to check the type of data stored in a given variable. Consider the examples from above. >>> type(var1) str >>> type(var2) int >>> type(var3) float >>> type(var4) bool As you can see, Python knows the data type of each variable. str refers to a character string for var1, int tells us var2 is an integer (or whole number), the float type for var3 indicates it is a floating point (or decimal) number and bool for var4 tells us it is a boolean variable. In each case, these types are dynamically assigned by Python when the variable is defined, hence dynamic data typing. Most of the time you won't have any data type problems, but the two examples below illustrate features you should keep in mind. >>> var5 = 2 >>> var6 = var2 / var5 >>> var6 0 >>> type(var6) int >>> var7 = var3 / var5 >>> var >>> type(var7) float What we can see here is that dividing an integer by another integer returns a value that is also an integer. In this case, since the integer 1 cannot be divided by 2 as a whole number, the resulting value is 0 for var6. For var7, we see that dividing a floating point number by an integer returns a floating point number. The same thing would be true if you divide an integer by a floating point number. As you can see the data type matters. Matrix math with NumPy NumPy is a scientific computing package for Python that provides MATLAB-like arrays and many other numerical features. Like Matplotlib, it is included in Canopy and automatically available at the prompt. See for yourself:

8 >>> array = np.array([1,2,3,4,5]) So, what's going on here? We've defined a new variable array and the contents appear to be the same list we had used in the first example plot [ 1,2,3,4,5]. That is partly true. Here, we are using the NumPy array type to create an array with the values [1,2,3,4,5]. The NumPy functions are available in the NumPy library ( np), and creating an array is done using np.array. You might be wondering how a Python list and an NumPy array differ, and why you would want to use one over the other. The example below shows some differences. >>> a = [1,2,3,4,5] >>> a [1,2,3,4,5] >>> type(a) list >>> b = np.array([1,2,3,4,5]) >>> b array([1, 2, 3, 4, 5]) >>> type(b) numpy.ndarray First, we can see that the list a has the same values in it as the array b, but they have different types; a is a list, b is an array. Lists can contain a mixture of values of any of the four data types mentioned in the previous section ( str, int, float, bool), but all of the values in an array must be of the same type, typically int or float. This is the main difference between lists and arrays. In general, array operations are much faster for large arrays than their equivalent lists. Now that we know a bit about arrays, let's look at some ways we can fill arrays with values and interact with them. We'll start by defining an array x that ranges from 0 to 3*, calculating and plotting values that vary as a function of x. This can be done in two ways. >>> x = np.arange(0, 3*math.pi, 0.1) # x from 0 to 3* by constant increments of 0.1 >>> x = np.linspace(0, 3*math.pi, 100) # x from 0 to 3* in 100 equal increments >>> beta = 0.5 >>> y = beta*np.sin(x) >>> plot(x,y)

9 Hopefully your plot looks similar. What you can see in this example is we've defined an array x with either a constant increment between values in the array or a fixed number of values across the range. y is a function of the sine of x and our plot confirms this. Be aware that when you must use the NumPy sine function np.sin when calculating with array values More fun (?) with matrices We've already seen how to make 1-dimensional matrices with NumPy, but we can make 2-D matrices as well. There are two different ways to do this. >>> x = np.array([[1, 4, 7], [2, 5, 8], [3, 6, 9]]) or >>> x = np.array([1, 4, 7, 2, 5, 8, 3, 6, 9]) >>> x = x.reshape((3, 3)) In both cases, a 3x3 matrix x is created. >>> x array([[1, 4, 7], [2, 5, 8], [3, 6, 9]]) In the first case, the values on each row were enclosed in brackets while a second set of brackets enclosed the entire array. In the second case, we created a 1x9 array the same way we had previously and used the reshape function to convert it to a 3x3 array. If we'd like to extract a specific value from our array x, we can do that by referencing a specific location in the matrix. The format for array indexing is x( rows, columns). Thus,

10 >>> y = x[2,0] # Row index 2, column index 0 >>> y 3 We can extract values from an entire column using the colon (:) character. >>> y = x[:,1] >>> y array([4, 5, 6]) Notice that the middle column has been extracted. Let's check out a bit more matrix math. We'll start with a new array >>> a = np.array([1, 2, 3, 4, 5]) >>> a array([1, 2, 3, 4, 5]) >>> a = a + 1 # Add 1 to the array values >>> a array([2, 3, 4, 5, 6]) # Each value increases by 1 Let's create another array, b, and add it to a. >>> b = np.array([5, 4, 3, 2, 1]) >>> a + b array([7, 7, 7, 7, 7]) As you can see, the result is simply the sum of the values in a and b, added for each array index location. Multiplication of values in arrays can be done in two ways: Either by multiplying each value in the two arrays by their corresponding index, or by proper matrix multiplication (dot product). >>> a * b array([10, 12, 12, 10, 6]) >>> np.dot(a,b) 50 Matrix multiplication using NumPy works just the opposite of MATLAB. If you have used MATLAB in the past, be careful. Plotting in more detail As we have seen above, 2-D plots can be created using the Matplotlib function plot. We can plot two arrays by typing plot(x,y). The plot function can take multiple arguments, allowing you to plot a 1-D array as a function of its index value by typing plot(a), or a 2-D array using separate line colors for each column by typing plot(x). You can also include optional arguments that allow you to format the plot. As an example, consider the following >>> plot(a,b,'k--')

11 If you have the same values still stored in arrays a and b from earlier, you should now see a plot of a black dashed line with a slope of -1. In this case the ' k--' indicates a black line ( k) should be drawn with dashes (--). Some common color choices and line styles/symbols are shown below. Many more are listed in the documentation for plot, which you can access using help(plot). ========== ======== character color ========== ======== 'b' blue 'g' green 'r' red 'k' black ========== ======== ================ =============================== character description ================ =============================== '-' solid line style '--' dashed line style ':' dotted line style '.' point marker 'o' circle marker 's' square marker 'x' x marker ================ =============================== In addition to formatting the plots, we can also use the plot command to plot multiple lines at the same time. >>> y1 = np.random.rand(10) # np.random.rand(n) generates an array of n random numbers >>> y2 = np.linspace(1,0,10) >>> x = np.arange(10) # np.arange(n) creates an array of n numbers in increasing order from 0 >>> plot(x, y1, 'ks', x, y2, 'r-') >>> title('test of plot function') # Add a title >>> xlabel('x Axis') # Label the x axis >>> ylabel('y Axis') # Label the y axis

12 Another useful plot function is errorbar. This example will produce a plot of the random values y1 with an errorbar of ±0.1. >>> errorbar(x, y1, np.ones(10)*0.1) # np.ones(n) generates a 1-D array of length n filled with values of 1 >>> title('test of errorbar') >>> xlabel('x axis'); ylabel('y axis')

13 Adding text labels to plots As you have likely seen, titles and axis labels can be easily added to the plots generated by Matplotlib. You can also add text at a given location on a plot using the text function. >>> text(1,0.5,'here is some text') This will add the text 'Here is some text' at position x=1, y=0.5 on the plot. Changing the axes The plotting commands make their best guess for the axis ranges that will produce a good looking plot, but often you may want to change the axis ranges manually. The axis function will provide you with the current axis ranges for a given plot and a means for changing them. >>> axis () (0.0, 9.0, , ) >>> axis([2, 7, -0.2, 1.0]) [2, 7, -0.2, 1.0] When you change the axis ranges, you enter the ranges as [xmin xmax ymin ymax]. Note that this will allow you to flip the orientation of the axes, if desired. For example [2, 7, 1.0, -0.2] would reverse the y-axis in the example above. Creating script.py files While you're welcome to type commands into the Python prompt to perform your calculations, it is often helpful to save a list of command to a single file that can be read in Python to execute a series of commands. These files are known as.py files, and essentially, they contain a list of exactly what should be done to produce desired output. In Canopy, it may be easiest to start by simply copying commands you've typed into a new.py file. You can create a new.py file either by clicking on the Create a new file button in the Canopy editor, or going up to the menubar and selecting File New Python file. Below is an example of a simple.py file that you can copy and paste into a new document in the Canopy editor. Save the file as colorsines.py and click on the sideways green triangle at the top of the Canopy editor to test. You should see colorful sine curves. #!/usr/bin/python # -*- coding: latin-1 -*- # colorsines.py # # This program produces colorful sine curves # # dwhipp # Import NumPy from pylab import * def main(): # Define x from -2 to 2 in 100 steps x = np.linspace(-2*math.pi,2*math.pi,100) # Define y1 as the sine of x y1 = np.sin(x) # Define y2, y3, y4, y5 as y1 multiplied by 0.8, 0,6, 0.4, 0.2 y2 = y1 * 0.8 y3 = y1 * 0.6 y4 = y1 * 0.4 y5 = y1 * 0.2 # Plot y1, y2, y3, y4 and y5 as a function of x in different colors

14 main() plot(x, y1, 'k-', x, y2, 'r-', x, y3, 'b-', x, y4, 'g-', x, y5, 'm-') # Add a plot title and axis labels title('my script plot') xlabel('x axis') ylabel('y axis') # Display the plot show() Here we see a few new things. First, Canopy normally automatically sets up NumPy and Matplotlib, but we need to import those functions to use them in a script with the command from pylab import *. Second, we've placed the array definitions and plotting stuff in a defined function called main. We simply define a new function within the code, then call the function at the end to execute the commands. When you write your first python scripts, it is a good idea to follow this design. Lastly, in order to display a plot in a script you must use the show() function. Any formatting of the plot must be listed prior to the show() function. When you define a function in Python, all of the commands that are part of the function must be indented to the same level. Typically, this indentation is 4 spaces. Exercises The exercises below are intended to help you become more familiar with the use of Python and NumPy. For each of the exercises, you are asked to submit a diary of commands that were run to generate the desired output, some code and/or a plot, and a few paragraphs summarizing the exercise. You can produce a diary of commands you have entered using the history command in Python. If you type history, you will see all of the commands you have entered during this Python session. Select the relevant commands for the exercise, copy them and paste them into a new text file using the Canopy editor. Exercise 1 - Fun with matrices Create three 3x3 matrices a, b and c with the following values: \( a = \left[ \begin{matrix} 1 & 5 & 3\\ 5 & 2 & 8\\ 4 & 7 & 2 \end{matrix} \right]\text{ } b = \left[ \begin{matrix} 3 & 3 & 5\\ 7 & 2 & 4\\ 6 & 2 & 3 \end {matrix} \right]\text{ } c = \left[ \begin{matrix} 2 & 6 & 8\\ 6 & 3 & 8\\ 9 & 9 & 3 \end{matrix} \right] \) Please provide your diary (command history) and solutions to the following problems Add the values in matrix a to matrix b Subtract matrix a from matrix c Multiply the values in matrix b by 4 Multiply the values in matrix b with matrix c. I want the product of the values in each location of the matrix, as shown in the example below for a 2x2 matrix. Example: \( \text{multiply }\left[ \begin{matrix} 1 & 2\\ 4 & 3 \end{matrix}\right] \text{ by }\left[ \begin{matrix} 3 & 4\\ 1 & 2 \end{matrix}\right] \text{ to get }\left[ \begin{matrix} 3 & 8\\ 4 & 6 \end{matrix}\right] \) For this exercise, provide a command history for the problems above. Exercise 2 - Plotting everything but the kitchen sinc (?) For this exercise you need to produce a Python script.py file that plots the sinc function from 0 to 8. The sinc function is equal to the sin(*x)/ (*x). This function is the continuous inverse Fourier transform of the rectangular pulse of width 2 and height 1. You can create a new.py file by clicking on File New Python file in the menubar. Your script should Create a 1-D array x that goes from 0 to 8 by increments of 0.1 and a variable y that is the sinc(x). Plot the values of y as a function of x with grid lines in the background of the plot (see help(grid) for guidance), label the axes appropriately and give the plot a title. Contain comments on each line of the code describing what the code does. For this exercise, please submit a printout of the Python script file you've written and a printout of the plot the.py file creates. Exercise 3 - "Decoding" other people's Python code

15 Typically, you don't start writing a Python code from scratch when you want to do calculations and/or real science. Most of the time someone else has already written a code that is similar to what you want to do, and your goal is to modify the code to suit your needs. Step one is to figure out what the code is supposed to do before you start tinkering. For this exercise, download the example Python script Mohr_circle_D-P_2D.py and save a copy on the Desktop or in another directory. If you navigate to the file in the Canopy editor using the panel on the left, you can double-click on the file and then click the sideways green triangle at the top of the Canopy window to run the code. Please answer the following questions: What is the purpose of this code, what does it do, and does it appear to work properly? What are the commands you recognize in the code? What are the commands you do not recognize? Are the comments sufficient for "decoding" this code as a new user? Why or why not? For this exercise, please submit a printout of your typed responses to the questions above.

MATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab

MATH (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab MATH 495.3 (CRN 13695) Lab 1: Basics for Linear Algebra and Matlab Below is a screen similar to what you should see when you open Matlab. The command window is the large box to the right containing the

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

Scientific Computing: Lecture 1

Scientific Computing: Lecture 1 Scientific Computing: Lecture 1 Introduction to course, syllabus, software Getting started Enthought Canopy, TextWrangler editor, python environment, ipython, unix shell Data structures in Python Integers,

More information

Chapter 1 Introduction to MATLAB

Chapter 1 Introduction to MATLAB Chapter 1 Introduction to MATLAB 1.1 What is MATLAB? MATLAB = MATrix LABoratory, the language of technical computing, modeling and simulation, data analysis and processing, visualization and graphics,

More information

Matlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name:

Matlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name: 1 Matlab Tutorial 1- What is Matlab? Matlab is a powerful tool for almost any kind of mathematical application. It enables one to develop programs with a high degree of functionality. The user can write

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

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

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

Introduction to Python Practical 1

Introduction to Python Practical 1 Introduction to Python Practical 1 Daniel Carrera & Brian Thorsbro October 2017 1 Introduction I believe that the best way to learn programming is hands on, and I tried to design this practical that way.

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 MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX 1) Objective The objective of this lab is to review how to access Matlab, Simulink, and the Communications Toolbox, and to become familiar

More information

Semester 2, 2018: Lab 1

Semester 2, 2018: Lab 1 Semester 2, 2018: Lab 1 S2 2018 Lab 1 This lab has two parts. Part A is intended to help you familiarise yourself with the computing environment found on the CSIT lab computers which you will be using

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

Overview. Lecture 13: Graphics and Visualisation. Graphics & Visualisation 2D plotting. Graphics and visualisation of data in Matlab

Overview. Lecture 13: Graphics and Visualisation. Graphics & Visualisation 2D plotting. Graphics and visualisation of data in Matlab Overview Lecture 13: Graphics and Visualisation Graphics & Visualisation 2D plotting 1. Plots for one or multiple sets of data, logarithmic scale plots 2. Axis control & Annotation 3. Other forms of 2D

More information

What is MATLAB? It is a high-level programming language. for numerical computations for symbolic computations for scientific visualizations

What is MATLAB? It is a high-level programming language. for numerical computations for symbolic computations for scientific visualizations What is MATLAB? It stands for MATrix LABoratory It is developed by The Mathworks, Inc (http://www.mathworks.com) It is an interactive, integrated, environment for numerical computations for symbolic computations

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

12 whereas if I terminate the expression with a semicolon, the printed output is suppressed.

12 whereas if I terminate the expression with a semicolon, the printed output is suppressed. Example 4 Printing and Plotting Matlab provides numerous print and plot options. This example illustrates the basics and provides enough detail that you can use it for typical classroom work and assignments.

More information

EGR 111 Introduction to MATLAB

EGR 111 Introduction to MATLAB EGR 111 Introduction to MATLAB This lab introduces the MATLAB help facility, shows how MATLAB TM, which stands for MATrix LABoratory, can be used as an advanced calculator. This lab also introduces assignment

More information

A/D Converter. Sampling. Figure 1.1: Block Diagram of a DSP System

A/D Converter. Sampling. Figure 1.1: Block Diagram of a DSP System CHAPTER 1 INTRODUCTION Digital signal processing (DSP) technology has expanded at a rapid rate to include such diverse applications as CDs, DVDs, MP3 players, ipods, digital cameras, digital light processing

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

Objectives. 1 Running, and Interface Layout. 2 Toolboxes, Documentation and Tutorials. 3 Basic Calculations. PS 12a Laboratory 1 Spring 2014

Objectives. 1 Running, and Interface Layout. 2 Toolboxes, Documentation and Tutorials. 3 Basic Calculations. PS 12a Laboratory 1 Spring 2014 PS 12a Laboratory 1 Spring 2014 Objectives This session is a tutorial designed to a very quick overview of some of the numerical skills that you ll need to get started. Throughout the tutorial, the instructors

More information

INTRODUCTION TO MATLAB

INTRODUCTION TO MATLAB 1 of 18 BEFORE YOU BEGIN PREREQUISITE LABS None EXPECTED KNOWLEDGE Algebra and fundamentals of linear algebra. EQUIPMENT None MATERIALS None OBJECTIVES INTRODUCTION TO MATLAB After completing this lab

More information

Interactive Mode Python Pylab

Interactive Mode Python Pylab Short Python Intro Gerald Schuller, Nov. 2016 Python can be very similar to Matlab, very easy to learn if you already know Matlab, it is Open Source (unlike Matlab), it is easy to install, and unlike Matlab

More information

ERTH3021 Exploration and Mining Geophysics

ERTH3021 Exploration and Mining Geophysics ERTH3021 Exploration and Mining Geophysics Practical 1: Introduction to Scientific Programming using Python Purposes To introduce simple programming skills using the popular Python language. To provide

More information

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB?

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB? Appendix A Introduction to MATLAB A.1 What Is MATLAB? MATLAB is a technical computing environment developed by The Math- Works, Inc. for computation and data visualization. It is both an interactive system

More information

CS1114: Matlab Introduction

CS1114: Matlab Introduction CS1114: Matlab Introduction 1 Introduction The purpose of this introduction is to provide you a brief introduction to the features of Matlab that will be most relevant to your work in this course. Even

More information

Once you define a new command, you can try it out by entering the command in IDLE:

Once you define a new command, you can try it out by entering the command in IDLE: 1 DEFINING NEW COMMANDS In the last chapter, we explored one of the most useful features of the Python programming language: the use of the interpreter in interactive mode to do on-the-fly programming.

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

2.0 MATLAB Fundamentals

2.0 MATLAB Fundamentals 2.0 MATLAB Fundamentals 2.1 INTRODUCTION MATLAB is a computer program for computing scientific and engineering problems that can be expressed in mathematical form. The name MATLAB stands for MATrix LABoratory,

More information

1. BASICS OF PYTHON. JHU Physics & Astronomy Python Workshop Lecturer: Mubdi Rahman

1. BASICS OF PYTHON. JHU Physics & Astronomy Python Workshop Lecturer: Mubdi Rahman 1. BASICS OF PYTHON JHU Physics & Astronomy Python Workshop 2017 Lecturer: Mubdi Rahman HOW IS THIS WORKSHOP GOING TO WORK? We will be going over all the basics you need to get started and get productive

More information

Matlab Introduction. Scalar Variables and Arithmetic Operators

Matlab Introduction. Scalar Variables and Arithmetic Operators Matlab Introduction Matlab is both a powerful computational environment and a programming language that easily handles matrix and complex arithmetic. It is a large software package that has many advanced

More information

MATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks

MATLAB Basics. Configure a MATLAB Package 6/7/2017. Stanley Liang, PhD York University. Get a MATLAB Student License on Matworks MATLAB Basics Stanley Liang, PhD York University Configure a MATLAB Package Get a MATLAB Student License on Matworks Visit MathWorks at https://www.mathworks.com/ It is recommended signing up with a student

More information

MATLAB Project: Getting Started with MATLAB

MATLAB Project: Getting Started with MATLAB Name Purpose: To learn to create matrices and use various MATLAB commands for reference later MATLAB built-in functions used: [ ] : ; + - * ^, size, help, format, eye, zeros, ones, diag, rand, round, cos,

More information

Prof. Manoochehr Shirzaei. RaTlab.asu.edu

Prof. Manoochehr Shirzaei. RaTlab.asu.edu RaTlab.asu.edu Introduction To MATLAB Introduction To MATLAB This lecture is an introduction of the basic MATLAB commands. We learn; Functions Procedures for naming and saving the user generated files

More information

Programming for Engineers in Python

Programming for Engineers in Python Programming for Engineers in Python Autumn 2016-17 Lecture 11: NumPy & SciPy Introduction, Plotting and Data Analysis 1 Today s Plan Introduction to NumPy & SciPy Plotting Data Analysis 2 NumPy and SciPy

More information

LAB 1 General MATLAB Information 1

LAB 1 General MATLAB Information 1 LAB 1 General MATLAB Information 1 General: To enter a matrix: > type the entries between square brackets, [...] > enter it by rows with elements separated by a space or comma > rows are terminated by

More information

CME 193: Introduction to Scientific Python Lecture 1: Introduction

CME 193: Introduction to Scientific Python Lecture 1: Introduction CME 193: Introduction to Scientific Python Lecture 1: Introduction Nolan Skochdopole stanford.edu/class/cme193 1: Introduction 1-1 Contents Administration Introduction Basics Variables Control statements

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

python 01 September 16, 2016

python 01 September 16, 2016 python 01 September 16, 2016 1 Introduction to Python adapted from Steve Phelps lectures - (http://sphelps.net) 2 Python is interpreted Python is an interpreted language (Java and C are not). In [1]: 7

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

NumPy quick reference

NumPy quick reference John W. Shipman 2016-05-30 12:28 Abstract A guide to the more common functions of NumPy, a numerical computation module for the Python programming language. This publication is available in Web form1 and

More information

Week - 01 Lecture - 04 Downloading and installing Python

Week - 01 Lecture - 04 Downloading and installing Python Programming, Data Structures and Algorithms in Python Prof. Madhavan Mukund Department of Computer Science and Engineering Indian Institute of Technology, Madras Week - 01 Lecture - 04 Downloading and

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

Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin

Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming using familiar mathematical notation The name Matlab stands

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

HERIOT-WATT UNIVERSITY DEPARTMENT OF COMPUTING AND ELECTRICAL ENGINEERING. B35SD2 Matlab tutorial 1 MATLAB BASICS

HERIOT-WATT UNIVERSITY DEPARTMENT OF COMPUTING AND ELECTRICAL ENGINEERING. B35SD2 Matlab tutorial 1 MATLAB BASICS HERIOT-WATT UNIVERSITY DEPARTMENT OF COMPUTING AND ELECTRICAL ENGINEERING Objectives: B35SD2 Matlab tutorial 1 MATLAB BASICS Matlab is a very powerful, high level language, It is also very easy to use.

More information

Matlab Tutorial and Exercises for COMP61021

Matlab Tutorial and Exercises for COMP61021 Matlab Tutorial and Exercises for COMP61021 1 Introduction This is a brief Matlab tutorial for students who have not used Matlab in their programming. Matlab programming is essential in COMP61021 as a

More information

Fundamentals: Expressions and Assignment

Fundamentals: Expressions and Assignment Fundamentals: Expressions and Assignment A typical Python program is made up of one or more statements, which are executed, or run, by a Python console (also known as a shell) for their side effects e.g,

More information

NumPy. Daniël de Kok. May 4, 2017

NumPy. Daniël de Kok. May 4, 2017 NumPy Daniël de Kok May 4, 2017 Introduction Today Today s lecture is about the NumPy linear algebra library for Python. Today you will learn: How to create NumPy arrays, which store vectors, matrices,

More information

MATLAB Project: Getting Started with MATLAB

MATLAB Project: Getting Started with MATLAB Name Purpose: To learn to create matrices and use various MATLAB commands for reference later MATLAB functions used: [ ] : ; + - * ^, size, help, format, eye, zeros, ones, diag, rand, round, cos, sin,

More information

University of Alberta

University of Alberta A Brief Introduction to MATLAB University of Alberta M.G. Lipsett 2008 MATLAB is an interactive program for numerical computation and data visualization, used extensively by engineers for analysis of systems.

More information

INTRODUCTION TO MATLAB PLOTTING WITH MATLAB

INTRODUCTION TO MATLAB PLOTTING WITH MATLAB 1 INTRODUCTION TO MATLAB PLOTTING WITH MATLAB Plotting with MATLAB x-y plot Plotting with MATLAB MATLAB contains many powerful functions for easily creating plots of several different types. Command plot(x,y)

More information

MATLAB = MATrix LABoratory. Interactive system. Basic data element is an array that does not require dimensioning.

MATLAB = MATrix LABoratory. Interactive system. Basic data element is an array that does not require dimensioning. Introduction MATLAB = MATrix LABoratory Interactive system. Basic data element is an array that does not require dimensioning. Efficient computation of matrix and vector formulations (in terms of writing

More information

Physics 326 Matlab Primer. A Matlab Primer. See the file basics.m, which contains much of the following.

Physics 326 Matlab Primer. A Matlab Primer. See the file basics.m, which contains much of the following. A Matlab Primer Here is how the Matlab workspace looks on my laptop, which is running Windows Vista. Note the presence of the Command Window in the center of the display. You ll want to create a folder

More information

Lab 1 Intro to MATLAB and FreeMat

Lab 1 Intro to MATLAB and FreeMat Lab 1 Intro to MATLAB and FreeMat Objectives concepts 1. Variables, vectors, and arrays 2. Plotting data 3. Script files skills 1. Use MATLAB to solve homework problems 2. Plot lab data and mathematical

More information

,!7IA3C1-cjfcei!:t;K;k;K;k ISBN Graphing Calculator Reference Card. Addison-Wesley s. Basics. Created in conjuction with

,!7IA3C1-cjfcei!:t;K;k;K;k ISBN Graphing Calculator Reference Card. Addison-Wesley s. Basics. Created in conjuction with Addison-Wesley s Graphing Calculator Reference Card Created in conjuction with Basics Converting Fractions to Decimals The calculator will automatically convert a fraction to a decimal. Type in a fraction,

More information

Dr Richard Greenaway

Dr Richard Greenaway SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 4 Visualising Data Dr Richard Greenaway 4 Visualising Data 4.1 Simple Data Plotting You should now be familiar with the plot function which is

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

Scientific Computing with MATLAB

Scientific Computing with MATLAB Scientific Computing with MATLAB Dra. K.-Y. Daisy Fan Department of Computer Science Cornell University Ithaca, NY, USA UNAM IIM 2012 2 Focus on computing using MATLAB Computer Science Computational Science

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

Introduction to MATLAB LAB 1

Introduction to MATLAB LAB 1 Introduction to MATLAB LAB 1 1 Basics of MATLAB MATrix LABoratory A super-powerful graphing calculator Matrix based numeric computation Embedded Functions Also a programming language User defined functions

More information

AMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA

AMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA AMATH 352: MATLAB Tutorial written by Peter Blossey Department of Applied Mathematics University of Washington Seattle, WA MATLAB (short for MATrix LABoratory) is a very useful piece of software for numerical

More information

Introduction to MATLAB. Simon O Keefe Non-Standard Computation Group

Introduction to MATLAB. Simon O Keefe Non-Standard Computation Group Introduction to MATLAB Simon O Keefe Non-Standard Computation Group sok@cs.york.ac.uk Content n An introduction to MATLAB n The MATLAB interfaces n Variables, vectors and matrices n Using operators n Using

More information

Week 1: Introduction to R, part 1

Week 1: Introduction to R, part 1 Week 1: Introduction to R, part 1 Goals Learning how to start with R and RStudio Use the command line Use functions in R Learning the Tools What is R? What is RStudio? Getting started R is a computer program

More information

Computer Lab 1: Introduction to Python

Computer Lab 1: Introduction to Python Computer Lab 1: Introduction to Python 1 I. Introduction Python is a programming language that is fairly easy to use. We will use Python for a few computer labs, beginning with this 9irst introduction.

More information

Programming in Mathematics. Mili I. Shah

Programming in Mathematics. Mili I. Shah Programming in Mathematics Mili I. Shah Starting Matlab Go to http://www.loyola.edu/moresoftware/ and login with your Loyola name and password... Matlab has eight main windows: Command Window Figure Window

More information

Getting Started with MATLAB

Getting Started with MATLAB Getting Started with MATLAB Math 315, Fall 2003 Matlab is an interactive system for numerical computations. It is widely used in universities and industry, and has many advantages over languages such as

More information

CS1114: Matlab Introduction

CS1114: Matlab Introduction CS1114: Matlab Introduction 1 Introduction The purpose of this introduction is to provide you a brief introduction to the features of Matlab that will be most relevant to your work in this course. Even

More information

Episode 1 Using the Interpreter

Episode 1 Using the Interpreter Episode 1 Using the Interpreter Anaconda We recommend, but do not require, the Anaconda distribution from Continuum Analytics (www.continuum.io). An overview is available at https://docs.continuum.io/anaconda.

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

Choose the file menu, and select Open. Input to be typed at the Maple prompt. Output from Maple. An important tip.

Choose the file menu, and select Open. Input to be typed at the Maple prompt. Output from Maple. An important tip. MAPLE Maple is a powerful and widely used mathematical software system designed by the Computer Science Department of the University of Waterloo. It can be used for a variety of tasks, such as solving

More information

Introduction to the workbook and spreadsheet

Introduction to the workbook and spreadsheet Excel Tutorial To make the most of this tutorial I suggest you follow through it while sitting in front of a computer with Microsoft Excel running. This will allow you to try things out as you follow along.

More information

The Very Basics of the R Interpreter

The Very Basics of the R Interpreter Chapter 2 The Very Basics of the R Interpreter OK, the computer is fired up. We have R installed. It is time to get started. 1. Start R by double-clicking on the R desktop icon. 2. Alternatively, open

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

OUTLINES. Variable names in MATLAB. Matrices, Vectors and Scalar. Entering a vector Colon operator ( : ) Mathematical operations on vectors.

OUTLINES. Variable names in MATLAB. Matrices, Vectors and Scalar. Entering a vector Colon operator ( : ) Mathematical operations on vectors. 1 LECTURE 3 OUTLINES Variable names in MATLAB Examples Matrices, Vectors and Scalar Scalar Vectors Entering a vector Colon operator ( : ) Mathematical operations on vectors examples 2 VARIABLE NAMES IN

More information

In the first class, you'll learn how to create a simple single-view app, following a 3-step process:

In the first class, you'll learn how to create a simple single-view app, following a 3-step process: Class 1 In the first class, you'll learn how to create a simple single-view app, following a 3-step process: 1. Design the app's user interface (UI) in Xcode's storyboard. 2. Open the assistant editor,

More information

Patterning Math Lab 4a

Patterning Math Lab 4a Patterning Math Lab 4a This lab is an exploration of transformations of functions, a topic covered in your Precalculus textbook in Section 1.5. As you do the exercises in this lab you will be closely reading

More information

Math 2250 MATLAB TUTORIAL Fall 2005

Math 2250 MATLAB TUTORIAL Fall 2005 Math 2250 MATLAB TUTORIAL Fall 2005 Math Computer Lab The Mathematics Computer Lab is located in the T. Benny Rushing Mathematics Center (located underneath the plaza connecting JWB and LCB) room 155C.

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

Introduction to MATLAB

Introduction to MATLAB Chapter 1 Introduction to MATLAB 1.1 Software Philosophy Matrix-based numeric computation MATrix LABoratory built-in support for standard matrix and vector operations High-level programming language Programming

More information

Programming with Python

Programming with Python Programming with Python Dr Ben Dudson Department of Physics, University of York 21st January 2011 http://www-users.york.ac.uk/ bd512/teaching.shtml Dr Ben Dudson Introduction to Programming - Lecture 2

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

The Mathcad Workspace 7

The Mathcad Workspace 7 For information on system requirements and how to install Mathcad on your computer, refer to Chapter 1, Welcome to Mathcad. When you start Mathcad, you ll see a window like that shown in Figure 2-1. By

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

A General Introduction to Matlab

A General Introduction to Matlab Master Degree Course in ELECTRONICS ENGINEERING http://www.dii.unimore.it/~lbiagiotti/systemscontroltheory.html A General Introduction to Matlab e-mail: luigi.biagiotti@unimore.it http://www.dii.unimore.it/~lbiagiotti

More information

ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu

ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu 0. What is MATLAB? 1 MATLAB stands for matrix laboratory and is one of the most popular software for numerical computation. MATLAB s basic

More information

Matlab Tutorial for COMP24111 (includes exercise 1)

Matlab Tutorial for COMP24111 (includes exercise 1) Matlab Tutorial for COMP24111 (includes exercise 1) 1 Exercises to be completed by end of lab There are a total of 11 exercises through this tutorial. By the end of the lab, you should have completed the

More information

Introduction to MATLAB. Computational Probability and Statistics CIS 2033 Section 003

Introduction to MATLAB. Computational Probability and Statistics CIS 2033 Section 003 Introduction to MATLAB Computational Probability and Statistics CIS 2033 Section 003 About MATLAB MATLAB (MATrix LABoratory) is a high level language made for: Numerical Computation (Technical computing)

More information

This Worksheet shows you several ways to start using Enthought s distribution of Python!

This Worksheet shows you several ways to start using Enthought s distribution of Python! This Worksheet shows you several ways to start using Enthought s distribution of Python! Start the Terminal application by Selecting the Utilities item from the Go menu located at the top of the screen

More information

Downloaded from Chapter 2. Functions

Downloaded from   Chapter 2. Functions Chapter 2 Functions After studying this lesson, students will be able to: Understand and apply the concept of module programming Write functions Identify and invoke appropriate predefined functions Create

More information

Lecturer: Keyvan Dehmamy

Lecturer: Keyvan Dehmamy MATLAB Tutorial Lecturer: Keyvan Dehmamy 1 Topics Introduction Running MATLAB and MATLAB Environment Getting help Variables Vectors, Matrices, and linear Algebra Mathematical Functions and Applications

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Basics MATLAB is a high-level interpreted language, and uses a read-evaluate-print loop: it reads your command, evaluates it, then prints the answer. This means it works a lot like

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

Desktop Command window

Desktop Command window Chapter 1 Matlab Overview EGR1302 Desktop Command window Current Directory window Tb Tabs to toggle between Current Directory & Workspace Windows Command History window 1 Desktop Default appearance Command

More information

Course May 18, Advanced Computational Physics. Course Hartmut Ruhl, LMU, Munich. People involved. SP in Python: 3 basic points

Course May 18, Advanced Computational Physics. Course Hartmut Ruhl, LMU, Munich. People involved. SP in Python: 3 basic points May 18, 2017 3 I/O 3 I/O 3 I/O 3 ASC, room A 238, phone 089-21804210, email hartmut.ruhl@lmu.de Patrick Böhl, ASC, room A205, phone 089-21804640, email patrick.boehl@physik.uni-muenchen.de. I/O Scientific

More information

Years after US Student to Teacher Ratio

Years after US Student to Teacher Ratio The goal of this assignment is to create a scatter plot of a set of data. You could do this with any two columns of data, but for demonstration purposes we ll work with the data in the table below. The

More information

The value of f(t) at t = 0 is the first element of the vector and is obtained by

The value of f(t) at t = 0 is the first element of the vector and is obtained by MATLAB Tutorial This tutorial will give an overview of MATLAB commands and functions that you will need in ECE 366. 1. Getting Started: Your first job is to make a directory to save your work in. Unix

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

Slide 1 CS 170 Java Programming 1 Multidimensional Arrays Duration: 00:00:39 Advance mode: Auto

Slide 1 CS 170 Java Programming 1 Multidimensional Arrays Duration: 00:00:39 Advance mode: Auto CS 170 Java Programming 1 Working with Rows and Columns Slide 1 CS 170 Java Programming 1 Duration: 00:00:39 Create a multidimensional array with multiple brackets int[ ] d1 = new int[5]; int[ ][ ] d2;

More information

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller

Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Excel Basics Rice Digital Media Commons Guide Written for Microsoft Excel 2010 Windows Edition by Eric Miller Table of Contents Introduction!... 1 Part 1: Entering Data!... 2 1.a: Typing!... 2 1.b: Editing

More information