(1) Generate 1000 samples of length 1000 drawn from the uniform distribution on the interval [0, 1].

Size: px
Start display at page:

Download "(1) Generate 1000 samples of length 1000 drawn from the uniform distribution on the interval [0, 1]."

Transcription

1 PRACTICAL EXAMPLES: SET 1 (1) Generate 1000 samples of length 1000 drawn from the uniform distribution on the interval [0, 1]. >> T=rand(1000,1000); The command above generates a matrix, whose columns (and rows) are filled with random numbers drawn from a uniform distribution on the interval [0, 1]. The same matrix could have been generated with the command "T=rand(1000);" the two indices in the example above allow one to generate non-square random matrices. A single uniform random deviate can be generated by just typing "rand" in your MATLAB window: repeated calls to "rand" will produce a set of random numbers. See "help rand" for more info.! Note that the command entry is followed by a semicolon; if you skip the semicolon, your matrix entries will be displayed in your MATLAB window (in general, you don't want this to happen, especially if the data set is large; however, the result of a single computation or the contents of small arrays can in principle be output in this way for example, you can type "rand" in your MATLAB window and see the resulting number).

2 ! Your workspace variables (a variable "T" and its dimensions in the example above) and command history ("T=rand(1000,1000);" in the example above) are displayed either in separate windows or on the left of the main MATLAB screen. You can also see your workspace variables in your main MATLAB window by typing "whos" (it will also take the commands of the type "whos T" and "whos T* a* b* c*" in the latter case, all variables that start with letters T, a, b, c will be displayed). To clear workspace, use command "clear"; you may also clear selected variables for example, "clear a*". MATLAB window is a UNIX window and you can use there UNIX commands such as "cd" to change a directory etc. To see the contents of the directory you are currently in, you should type "!ls". You can also use an upper-arrow key to get (within MATLAB) to a previously issued command (try it to issue the command "T=rand(1000,1000);" again). You can also explore other ways of displaying a MATLAB session and/or moving within your computer by playing with the Desktop layout options of the MATLAB "View" command on the top of your screen (at least if you are using Mac:). (2) Compute the average and dispersion of each sample as a function of sample size N. Use N=100, 200,..., 1000 and get the total of 1000 estimates of each of the two quantities for each of 10 sample sizes. >> for i=1:10 a(i,:)=mean(t(1:i*100,:));

3 end >> for i=1:10 s2(i,:)=var(t(1:i*100,:)); end The above example introduces several MATLAB operations setting up a for-loop cycle, working with matrix indices, as well as two intrinsic functions: mean and var. The for-loop cycle's text is placed in between the two commands: "for i=1:10" initiates the loop computations over a range of the loop index i; this command should be followed by pressing Enter and then you can type the cycle commands "a(i,:)=mean(t(1:i*100,:));" or "s2(i,:)=var(t(1:i*100,:));" (you could type several commands in one loop and separate them by pressing Enter). Finally, the cycle ends with the command "end" (then press Enter).! MATLAB is a vector-based software; the for-loops should only be used if the operations they perform cannot be written in a matrix form (as in the example above) the latter form produces a much faster computational speed. Two-dimensional matrices in MATLAB are stored in a column-wise order, so that a(i,j) refers to the i-th element of the j-th column. You can define a column vector as bc=a(:,j) or a row vector as br=a(i,:) (i/j are the indices of the column/row you would like to save as a vector); you can also form matrices of different size based on your original matrix, as is done in our example above: T(1:i*100,:) defines the matrix with 1000 columns and i*100 rows. The MATLAB intrinsic function mean(x) and var(x), if x is a vector

4 (one-dimensional sample of data), compute this data set's average and dispersion, respectively. In our case, the variable T is a matrix, so the result of applying mean(t(1:i*100),:) is a vector of dimension (1,1000) a row vector so that the averaging was also applied column-wise (you can also do row-wise averaging by using mean(t,2) and var(t,2); see "help mean" or "help var" for further details). Now you can see that the two for-loops exercised above produced exactly the data we wanted 1000 independent estimates of the average and dispersion based on random samples of size 100*i (i=1,2,..., 10) stored in vectors a(1:10,1:1000) and s2(1:10,1:1000).! Check out how your workspace variables list and your command history list have changed.! How to compute skewness, kurtosis or an arbitrary moment of a data sample in MATLAB? type "help skewness," "help kurtosis," or "help moment" to figure out! (3) Let's summarize: for our original samples of size N=100, 200,..., 1000, drawn from a uniform distribution on the interval [0, 1], we have 1000 independent estimates of the sample average a(n) and dispersion s2(n). We can now compute numerically the distribution of these derived quantities. The simplest way to do so is to plot the histogram (see "help hist"): >> hist(a(1,:),15)

5 The command above takes our vector data (in this case, 1000 estimates of sample means for N=100; "hist(a(2,:),15)" would plot the data that came from samples with N=200 etc.), computes its maximum and minimum values and divides the interval between these two values into 15 bins. It then counts, over the whole record, the number of data points with values belonging to each of the bins and displays the results as a box plot. Try plotting the histograms for the sample averages and dispersion using the data with increasing sample size (N=200+). Plot also the histograms of a dispersion. Pay attention to the fact that the range of the averages and dispersion decreases as the sample size increases both the average and dispersion become concentrated more and more near certain values as N becomes larger and larger.! If you type "hist(a(1,:),15) Enter hist(a(2,:),15)" in sequence, the first box plot will be cleared from the figure frame, and the second box plot will appear. If you want to compare the plots, you might want to call a separate figure before plotting the second histogram: "hist(a(1,:),15) Enter figure Enter hist(a(2,:),15)." Each figure will be assigned a number; you can edit the figure n by first pointing to it using the command "figure(n) Enter", and then typing the editing commands of your choice. For example, you want to label the axis and make a figure title (close all figures first): >>figure >>hist(a(1,:),15) >>figure >>hist(a(2,:),15)

6 >>figure(1) >>xlabel('a') >>ylabel('number of observations') >>title('histogram of a sample mean (N=100)') >>figure(2) >>xlabel('a') >>ylabel('number of observations') >>title('histogram of a sample mean (N=200)') >>set(gca,'xlim',[ ]) >>figure(1) >>set(gca,'xlim',[ ]) The last commands above set the x-axis limits to be the same (from 0.4 to 0.6) in both plots so that you could compare the two plots more easily ("gca" means "get current axes" and you can do a number of things using it change fonts and font sizes in the figure, colors, etc.). The histogram is not always convenient, since the total number of events depends on the sample size. A more convenient way to visualize our data would be to scale histograms to cover a unit area using command "histc" (see "help histc"). Here is an example of how to do it: >> mina=min(min(a));! min(x) computes minimum value of a vector or creates a row vector of column mins: min(min(a)) returns the entry of a 2-D matrix with the minimum (of all elements) value (see "help min") >> maxa=max(max(a));! maximum value of a matrix; we need the min and max values to determine the

7 range of our data >> da=(maxa-mina)/15;!divide the range into 15 equal intervals; da is the length of each interval >> edgesa=[mina:da:maxa];!define the vector of interval boundaries >> h1=histc(a(1,:),edgesa);!intrinsic function histc computes the number of observations (a(1,:)) that fall between the elements in the edgesa vector (see "help histc" for more info for example, histc can be applied, as everything in MATLAB, to matrices and tensors) >> whos h1 Name Size Bytes Class h1 1x double array Grand total is 16 elements using 128 bytes >> size(h1,1)!size command ans = 1 >> size(h1,2) ans = 16 >>h1=h1/(size(h1,2)*mean(h1,2));! normalize

8 >> mean(h1)*size(h1,2) ans = 1! Here is our unit area! >>figure >> plot(edgesa,h1)! plot the normalized histogram >> >> h10=histc(a(10,:),edgesa);! do the same for a different sample size (N=1000) >> h10=h10/(size(h10,2)*mean(h10,2)); >> hold on! retain the previous plot in the figure (the inverse command will be "hold off") >> plot(edgesa,h10,'r')! notice that we added color (default is blue). Type "help plot" for available line types and colors. >> legend('n=100','n=1000')! automatic figure legend >>xlabel('a') >>ylabel('p(a)') >>title('estimated PDF of an average of a sample of size N drawn from a uniform distribution on [0,1]') >>grid on! adds the grid (4) At your spare time, you can plot sample distributions of s2 in the same way. Notice that both the distributions of sample average and sample dispersion have a bell shape, with the top of the bell situated at the coordinate

9 corresponding to the expected values of a and s2; these numerically determined values appear to be independent of a sample size (as predicted by the theory). In contrast, the dispersion of the sample mean and sample dispersion (do not get confused: we are talking about "dispersion of a dispersion, " that is the quantity associated with the expected spread of individual samples' dispersions about their ensemble-mean value) both decrease as the sample size increases. Can we see how exactly these two quantities change? >>mean(a')! here is the expected value (ensemble average) of our sample means depending on the sample size (the prime is a transpose operator which changes rows into columns and vice versa) >>var(a')! dispersion of the sample average as a function of a sample size >>N=[100:100:1000]; sample sizes! vector of >>figure >>plot(n,1./var(a'),'x')! inverse of the sample dispersion as a function of N; the syntax 1./matrix means that the inverse of each matrix element is taken >>hold on >>plot(n,12*n,'r')! theoretical prediction

10 >>legend('numerical result','theoretical prediction') >>xlabel('n') >>ylabel('var{n}') >>title('numerical and theoretical estimates of the sample-mean\prime s dispersion as a function of a sample size N') >>grid on (5) You can also compute and compare the observed and theoretical values of the dispersion of s2. In the next lecture, we will derive the theoretical results for the expectation and variance of the sample's average and dispersion for a general case in which each observation is assumed to be drawn from a different (but known) theoretical distribution. It is a good idea to save your MATLAB session if you wish to be able to easily reproduce the results you have obtained previously. MATLAB saves your command history automatically, and it's possible to save it to a file with an extension.m, which you can then edit. For example, most of our present session could be saved in the file (matlab script) session1.m, which could look something like this: Session 1 (script session1.m) clear T=rand(1000,1000); you can put your comments here...

11 for i=1:10...or actually anywhere a(i,:)=mean(t(1:i*100,:)); end for i=1:10 s2(i,:)=var(t(1:i*100,:)); end figure Figure 1 hist(a(1,:),15) figure Figure 2 hist(a(2,:),15) figure(1) xlabel('a') ylabel('number of observations') title('histogram of a sample mean (N=100)') figure(2) xlabel('a') ylabel('number of observations') title('histogram of a sample mean (N=200)') set(gca,'xlim',[ ])

12 figure(1) set(gca,'xlim',[ ]) mina=min(min(a)); maxa=max(max(a)); da=(maxa-mina)/15; edgesa=[mina:da:maxa]; h1=histc(a(1,:),edgesa); whos h1 size(h1,1) size(h1,2) h1=h1/(size(h1,2)*mean(h1,2)); mean(h1)*size(h1,2) figure Figure 3 plot(edgesa,h1) h10=histc(a(10,:),edgesa); h10=h10/(size(h10,2)*mean(h10,2)); hold on plot(edgesa,h10,'r') legend('n=100','n=1000') xlabel('a')

13 ylabel('p(a)') title('estimated PDF of an average of a sample of size N drawn from a uniform distribution on [0,1]') grid on mean(a') var(a') N=[100:100:1000]; figure Figure 4 plot(n,1./var(a'),'x') hold on plot(n,12*n,'r') legend('numerical result','theoretical prediction') xlabel('n') ylabel('var{n}') title('numerical and theoretical estimates of the sample-mean\prime s dispersion as a function of a sample size N') grid on End of script

14 To run the script, change the directory to the one in which the script is stored (you can also add this directory to the MATLAB path see "set path" command of MATLAB menu) and type "session1 Enter"). You can now run the script however many times you want (notice that if you do it in sequence within the same MATLAB session, you will get different realizations of your uniformly-distributed samples and your results will be slightly different from one realization to another. The general result will hold, however, as your sample size increases, the distributions of sample-averaged quantities will become more and more concentrated in the vicinity of expected values, while the distributions of these quantities will be more and more Gaussian (we will discuss this important property shortly).

Outline. User-based knn Algorithm Basics of Matlab Control Structures Scripts and Functions Help

Outline. User-based knn Algorithm Basics of Matlab Control Structures Scripts and Functions Help Outline User-based knn Algorithm Basics of Matlab Control Structures Scripts and Functions Help User-based knn Algorithm Three main steps Weight all users with respect to similarity with the active user.

More information

Introduction to Matlab. By: Hossein Hamooni Fall 2014

Introduction to Matlab. By: Hossein Hamooni Fall 2014 Introduction to Matlab By: Hossein Hamooni Fall 2014 Why Matlab? Data analytics task Large data processing Multi-platform, Multi Format data importing Graphing Modeling Lots of built-in functions for rapid

More information

MATLAB GUIDE UMD PHYS375 FALL 2010

MATLAB GUIDE UMD PHYS375 FALL 2010 MATLAB GUIDE UMD PHYS375 FALL 200 DIRECTORIES Find the current directory you are in: >> pwd C:\Documents and Settings\ian\My Documents\MATLAB [Note that Matlab assigned this string of characters to a variable

More information

MATLAB TUTORIAL WORKSHEET

MATLAB TUTORIAL WORKSHEET MATLAB TUTORIAL WORKSHEET What is MATLAB? Software package used for computation High-level programming language with easy to use interactive environment Access MATLAB at Tufts here: https://it.tufts.edu/sw-matlabstudent

More information

Introduction to MATLAB

Introduction to MATLAB CHEE MATLAB Tutorial Introduction to MATLAB Introduction In this tutorial, you will learn how to enter matrices and perform some matrix operations using MATLAB. MATLAB is an interactive program for numerical

More information

Unix Computer To open MATLAB on a Unix computer, click on K-Menu >> Caedm Local Apps >> MATLAB.

Unix Computer To open MATLAB on a Unix computer, click on K-Menu >> Caedm Local Apps >> MATLAB. MATLAB Introduction This guide is intended to help you start, set up and understand the formatting of MATLAB before beginning to code. For a detailed guide to programming in MATLAB, read the MATLAB Tutorial

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 K. Craig 1

Introduction to MatLab. Introduction to MatLab K. Craig 1 Introduction to MatLab Introduction to MatLab K. Craig 1 MatLab Introduction MatLab and the MatLab Environment Numerical Calculations Basic Plotting and Graphics Matrix Computations and Solving Equations

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

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Introduction: MATLAB is a powerful high level scripting language that is optimized for mathematical analysis, simulation, and visualization. You can interactively solve problems

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

Getting started with MATLAB

Getting started with MATLAB Getting started with MATLAB You can work through this tutorial in the computer classes over the first 2 weeks, or in your own time. The Farber and Goldfarb computer classrooms have working Matlab, but

More information

Learning from Data Introduction to Matlab

Learning from Data Introduction to Matlab Learning from Data Introduction to Matlab Amos Storkey, David Barber and Chris Williams a.storkey@ed.ac.uk Course page : http://www.anc.ed.ac.uk/ amos/lfd/ This is a modified version of a text written

More information

Teaching Manual Math 2131

Teaching Manual Math 2131 Math 2131 Linear Algebra Labs with MATLAB Math 2131 Linear algebra with Matlab Teaching Manual Math 2131 Contents Week 1 3 1 MATLAB Course Introduction 5 1.1 The MATLAB user interface...........................

More information

LAB #2: SAMPLING, SAMPLING DISTRIBUTIONS, AND THE CLT

LAB #2: SAMPLING, SAMPLING DISTRIBUTIONS, AND THE CLT NAVAL POSTGRADUATE SCHOOL LAB #2: SAMPLING, SAMPLING DISTRIBUTIONS, AND THE CLT Statistics (OA3102) Lab #2: Sampling, Sampling Distributions, and the Central Limit Theorem Goal: Use R to demonstrate sampling

More information

% Close all figure windows % Start figure window

% Close all figure windows % Start figure window CS1112 Fall 2016 Project 3 Part A Due Monday 10/3 at 11pm You must work either on your own or with one partner. If you work with a partner, you must first register as a group in CMS and then submit your

More information

Finding MATLAB on CAEDM Computers

Finding MATLAB on CAEDM Computers Lab #1: Introduction to MATLAB Due Tuesday 5/7 at noon This guide is intended to help you start, set up and understand the formatting of MATLAB before beginning to code. For a detailed guide to programming

More information

Getting started with MATLAB

Getting started with MATLAB Sapienza University of Rome Department of economics and law Advanced Monetary Theory and Policy EPOS 2013/14 Getting started with MATLAB Giovanni Di Bartolomeo giovanni.dibartolomeo@uniroma1.it Outline

More information

Chapter 6: DESCRIPTIVE STATISTICS

Chapter 6: DESCRIPTIVE STATISTICS Chapter 6: DESCRIPTIVE STATISTICS Random Sampling Numerical Summaries Stem-n-Leaf plots Histograms, and Box plots Time Sequence Plots Normal Probability Plots Sections 6-1 to 6-5, and 6-7 Random Sampling

More information

MATLAB Introductory Course Computer Exercise Session

MATLAB Introductory Course Computer Exercise Session MATLAB Introductory Course Computer Exercise Session This course is a basic introduction for students that did not use MATLAB before. The solutions will not be collected. Work through the course within

More information

A 30 Minute Introduction to Octave ENGR Engineering Mathematics Tony Richardson

A 30 Minute Introduction to Octave ENGR Engineering Mathematics Tony Richardson A 30 Minute Introduction to Octave ENGR 390 - Engineering Mathematics Tony Richardson Introduction This is a brief introduction to Octave. It covers several topics related to both the statistics and linear

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

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

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Contents 1.1 Objectives... 1 1.2 Lab Requirement... 1 1.3 Background of MATLAB... 1 1.4 The MATLAB System... 1 1.5 Start of MATLAB... 3 1.6 Working Modes of MATLAB... 4 1.7 Basic

More information

MATLAB INTRODUCTION. Matlab can be used interactively as a super hand calculator, or, more powerfully, run using scripts (i.e., programs).

MATLAB INTRODUCTION. Matlab can be used interactively as a super hand calculator, or, more powerfully, run using scripts (i.e., programs). L A B 6 M A T L A B MATLAB INTRODUCTION Matlab is a commercial product that is used widely by students and faculty and researchers at UTEP. It provides a "high-level" programming environment for computing

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

CSCI 6906: Fundamentals of Computational Neuroimaging. Thomas P. Trappenberg Dalhousie University

CSCI 6906: Fundamentals of Computational Neuroimaging. Thomas P. Trappenberg Dalhousie University CSCI 6906: Fundamentals of Computational Neuroimaging Thomas P. Trappenberg Dalhousie University 1 Programming with Matlab This chapter is a brief introduction to programming with the Matlab programming

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

Working with Charts Stratum.Viewer 6

Working with Charts Stratum.Viewer 6 Working with Charts Stratum.Viewer 6 Getting Started Tasks Additional Information Access to Charts Introduction to Charts Overview of Chart Types Quick Start - Adding a Chart to a View Create a Chart with

More information

MATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano

MATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano MATLAB Lesson I Chiara Lelli Politecnico di Milano October 2, 2012 MATLAB MATLAB (MATrix LABoratory) is an interactive software system for: scientific computing statistical analysis vector and matrix computations

More information

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures

Introduction to Octave/Matlab. Deployment of Telecommunication Infrastructures Introduction to Octave/Matlab Deployment of Telecommunication Infrastructures 1 What is Octave? Software for numerical computations and graphics Particularly designed for matrix computations Solving equations,

More information

Objectives. 1 Basic Calculations. 2 Matrix Algebra. Physical Sciences 12a Lab 0 Spring 2016

Objectives. 1 Basic Calculations. 2 Matrix Algebra. Physical Sciences 12a Lab 0 Spring 2016 Physical Sciences 12a Lab 0 Spring 2016 Objectives This lab is a tutorial designed to a very quick overview of some of the numerical skills that you ll need to get started in this class. It is meant to

More information

STAT 391 Handout 1 Making Plots with Matlab Mar 26, 2006

STAT 391 Handout 1 Making Plots with Matlab Mar 26, 2006 STAT 39 Handout Making Plots with Matlab Mar 26, 26 c Marina Meilă & Lei Xu mmp@cs.washington.edu This is intended to help you mainly with the graphics in the homework. Matlab is a matrix oriented mathematics

More information

Intro to Matlab for GEOL 1520: Ocean Circulation and Climate or, Notions for the Motions of the Oceans

Intro to Matlab for GEOL 1520: Ocean Circulation and Climate or, Notions for the Motions of the Oceans Intro to Matlab for GEOL 50: Ocean Circulation and Climate or, Notions for the Motions of the Oceans Baylor Fox-Kemper January 6, 07 Contacts The professor for this class is: Baylor Fox-Kemper baylor@brown.edu

More information

1 Overview of the standard Matlab syntax

1 Overview of the standard Matlab syntax 1 Overview of the standard Matlab syntax Matlab is based on computations with matrices. All variables are matrices. Matrices are indexed from 1 (and NOT from 0 as in C!). Avoid using variable names i and

More information

Getting Started with MATLAB

Getting Started with MATLAB APPENDIX B Getting Started with MATLAB MATLAB software is a computer program that provides the user with a convenient environment for many types of calculations in particular, those that are related to

More information

Variable Definition and Statement Suppression You can create your own variables, and assign them values using = >> a = a = 3.

Variable Definition and Statement Suppression You can create your own variables, and assign them values using = >> a = a = 3. MATLAB Introduction Accessing Matlab... Matlab Interface... The Basics... 2 Variable Definition and Statement Suppression... 2 Keyboard Shortcuts... More Common Functions... 4 Vectors and Matrices... 4

More information

MATLAB: The Basics. Dmitry Adamskiy 9 November 2011

MATLAB: The Basics. Dmitry Adamskiy 9 November 2011 MATLAB: The Basics Dmitry Adamskiy adamskiy@cs.rhul.ac.uk 9 November 2011 1 Starting Up MATLAB Windows users: Start up MATLAB by double clicking on the MATLAB icon. Unix/Linux users: Start up by typing

More information

MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY

MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY What is MATLAB? MATLAB (MATrix LABoratory) developed by The Mathworks, Inc. (http://www.mathworks.com) Key Features: High-level language for numerical

More information

Functions of Two Variables

Functions of Two Variables Functions of Two Variables MATLAB allows us to work with functions of more than one variable With MATLAB 5 we can even move beyond the traditional M N matrix to matrices with an arbitrary number of dimensions

More information

INTRODUCTORY NOTES ON MATLAB

INTRODUCTORY NOTES ON MATLAB INTRODUCTORY NOTES ON MATLAB C Lamas Fernández, S Marelli, B Sudret CHAIR OF RISK, SAFETY AND UNCERTAINTY QUANTIFICATION STEFANO-FRANSCINI-PLATZ 5 CH-8093 ZÜRICH Risk, Safety & Uncertainty Quantification

More information

SAT Released Test 8 Problem #28

SAT Released Test 8 Problem #28 SAT Released Test 8 Problem #28 28.) The 22 students in a health class conducted an experiment in which they each recorded their pulse rates, in beats per minute, before and after completing a light exercise

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

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial

Constraint-based Metabolic Reconstructions & Analysis H. Scott Hinton. Matlab Tutorial. Lesson: Matlab Tutorial 1 Matlab Tutorial 2 Lecture Learning Objectives Each student should be able to: Describe the Matlab desktop Explain the basic use of Matlab variables Explain the basic use of Matlab scripts Explain the

More information

Practical 4: The Integrate & Fire neuron

Practical 4: The Integrate & Fire neuron Practical 4: The Integrate & Fire neuron 2014 version by Mark van Rossum 2018 version by Matthias Hennig and Theoklitos Amvrosiadis 16th October 2018 1 Introduction to MATLAB basics You can start MATLAB

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Christopher K. I. Williams Division of Informatics, University of Edinburgh October 1999 Background This document has the objective of introducing you to some of the facilities available

More information

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University Part 1 Chapter 2 MATLAB Fundamentals PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

More information

MATLAB Introduction. Contents. Introduction to Matlab. Published on Advanced Lab (

MATLAB Introduction. Contents. Introduction to Matlab. Published on Advanced Lab ( Published on Advanced Lab (http://experimentationlab.berkeley.edu) Home > References > MATLAB Introduction MATLAB Introduction Contents 1 Introduction to Matlab 1.1 About Matlab 1.2 Prepare Your Environment

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

Lab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013

Lab of COMP 406. MATLAB: Quick Start. Lab tutor : Gene Yu Zhao Mailbox: or Lab 1: 11th Sep, 2013 Lab of COMP 406 MATLAB: Quick Start Lab tutor : Gene Yu Zhao Mailbox: csyuzhao@comp.polyu.edu.hk or genexinvivian@gmail.com Lab 1: 11th Sep, 2013 1 Where is Matlab? Find the Matlab under the folder 1.

More information

MATLAB Lecture 1. Introduction to MATLAB

MATLAB Lecture 1. Introduction to MATLAB MATLAB Lecture 1. Introduction to MATLAB 1.1 The MATLAB environment MATLAB is a software program that allows you to compute interactively with matrices. If you want to know for instance the product of

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

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

MATLAB for beginners. KiJung Yoon, 1. 1 Center for Learning and Memory, University of Texas at Austin, Austin, TX 78712, USA

MATLAB for beginners. KiJung Yoon, 1. 1 Center for Learning and Memory, University of Texas at Austin, Austin, TX 78712, USA MATLAB for beginners KiJung Yoon, 1 1 Center for Learning and Memory, University of Texas at Austin, Austin, TX 78712, USA 1 MATLAB Tutorial I What is a matrix? 1) A way of representation for data (# of

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

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

Mathworks (company that releases Matlab ) documentation website is:

Mathworks (company that releases Matlab ) documentation website is: 1 Getting Started The Mathematics Behind Biological Invasions Introduction to Matlab in UNIX Christina Cobbold and Tomas de Camino Beck as modified for UNIX by Fred Adler Logging in: This is what you do

More information

Central Limit Theorem Sample Means

Central Limit Theorem Sample Means Date Central Limit Theorem Sample Means Group Member Names: Part One Review of Types of Distributions Consider the three graphs below. Match the histograms with the distribution description. Write the

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB What you will learn The most important commands (from my view) Writing scripts (.m files) Defining MATLAB variables Matrix/array operations Importing and extracting data 2D plots

More information

MATLAB - Lecture # 4

MATLAB - Lecture # 4 MATLAB - Lecture # 4 Script Files / Chapter 4 Topics Covered: 1. Script files. SCRIPT FILE 77-78! A script file is a sequence of MATLAB commands, called a program.! When a file runs, MATLAB executes the

More information

A Guide to Using Some Basic MATLAB Functions

A Guide to Using Some Basic MATLAB Functions A Guide to Using Some Basic MATLAB Functions UNC Charlotte Robert W. Cox This document provides a brief overview of some of the essential MATLAB functionality. More thorough descriptions are available

More information

CS129: Introduction to Matlab (Code)

CS129: Introduction to Matlab (Code) CS129: Introduction to Matlab (Code) intro.m Introduction to Matlab (adapted from http://www.stanford.edu/class/cs223b/matlabintro.html) Stefan Roth , 09/08/2003 Stolen

More information

Getting Started with MATLAB

Getting Started with MATLAB Getting Started with MATLAB Math 4600 Lab: Gregory Handy http://www.math.utah.edu/ borisyuk/4600/ Logging in for the first time: This is what you do to start working on the computer. If your machine seems

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

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

Chapter 2. MATLAB Fundamentals

Chapter 2. MATLAB Fundamentals Chapter 2. MATLAB Fundamentals Choi Hae Jin Chapter Objectives q Learning how real and complex numbers are assigned to variables. q Learning how vectors and matrices are assigned values using simple assignment,

More information

Introduction to R Programming

Introduction to R Programming Course Overview Over the past few years, R has been steadily gaining popularity with business analysts, statisticians and data scientists as a tool of choice for conducting statistical analysis of data

More information

CHAPTER 2: SAMPLING AND DATA

CHAPTER 2: SAMPLING AND DATA CHAPTER 2: SAMPLING AND DATA This presentation is based on material and graphs from Open Stax and is copyrighted by Open Stax and Georgia Highlands College. OUTLINE 2.1 Stem-and-Leaf Graphs (Stemplots),

More information

Table of Contents (As covered from textbook)

Table of Contents (As covered from textbook) Table of Contents (As covered from textbook) Ch 1 Data and Decisions Ch 2 Displaying and Describing Categorical Data Ch 3 Displaying and Describing Quantitative Data Ch 4 Correlation and Linear Regression

More information

Matlab Review. Dr. Mark Glauser, Created by: David Marr. Mechanical Engineering Syracuse University. Matlab Review p.

Matlab Review. Dr. Mark Glauser, Created by: David Marr. Mechanical Engineering Syracuse University. Matlab Review p. Matlab Review p.1 Matlab Review Dr. Mark Glauser, Created by: David Marr drmarr@syr.edu Mechanical Engineering Syracuse University General Info Matlab Review p.2 The Command Window is where you type in

More information

Matlab- Command Window Operations, Scalars and Arrays

Matlab- Command Window Operations, Scalars and Arrays 1 ME313 Homework #1 Matlab- Command Window Operations, Scalars and Arrays Last Updated August 17 2012. Assignment: Read and complete the suggested commands. After completing the exercise, copy the contents

More information

R practice. Eric Gilleland. 20th May 2015

R practice. Eric Gilleland. 20th May 2015 R practice Eric Gilleland 20th May 2015 1 Preliminaries 1. The data set RedRiverPortRoyalTN.dat can be obtained from http://www.ral.ucar.edu/staff/ericg. Read these data into R using the read.table function

More information

PC-MATLAB PRIMER. This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens.

PC-MATLAB PRIMER. This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens. PC-MATLAB PRIMER This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens. >> 2*3 ans = 6 PCMATLAB uses several lines for the answer, but I ve edited this to save space.

More information

Homework 1 Excel Basics

Homework 1 Excel Basics Homework 1 Excel Basics Excel is a software program that is used to organize information, perform calculations, and create visual displays of the information. When you start up Excel, you will see the

More information

What is Matlab? The command line Variables Operators Functions

What is Matlab? The command line Variables Operators Functions What is Matlab? The command line Variables Operators Functions Vectors Matrices Control Structures Programming in Matlab Graphics and Plotting A numerical computing environment Simple and effective programming

More information

Introduction to MATLAB. CS534 Fall 2016

Introduction to MATLAB. CS534 Fall 2016 Introduction to MATLAB CS534 Fall 2016 What you'll be learning today MATLAB basics (debugging, IDE) Operators Matrix indexing Image I/O Image display, plotting A lot of demos... Matrices What is a matrix?

More information

Matlab and Octave: Quick Introduction and Examples 1 Basics

Matlab and Octave: Quick Introduction and Examples 1 Basics Matlab and Octave: Quick Introduction and Examples 1 Basics 1.1 Syntax and m-files There is a shell where commands can be written in. All commands must either be built-in commands, functions, names of

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

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

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

Figure 1. Figure 2. The BOOTSTRAP

Figure 1. Figure 2. The BOOTSTRAP The BOOTSTRAP Normal Errors The definition of error of a fitted variable from the variance-covariance method relies on one assumption- that the source of the error is such that the noise measured has a

More information

MATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c.

MATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c. MATLAB BASICS Starting Matlab < PC: Desktop icon or Start menu item < UNIX: Enter matlab at operating system prompt < Others: Might need to execute from a menu somewhere Entering Matlab commands < Matlab

More information

Survey of Math: Excel Spreadsheet Guide (for Excel 2016) Page 1 of 9

Survey of Math: Excel Spreadsheet Guide (for Excel 2016) Page 1 of 9 Survey of Math: Excel Spreadsheet Guide (for Excel 2016) Page 1 of 9 Contents 1 Introduction to Using Excel Spreadsheets 2 1.1 A Serious Note About Data Security.................................... 2 1.2

More information

Introduction. Matlab for Psychologists. Overview. Coding v. button clicking. Hello, nice to meet you. Variables

Introduction. Matlab for Psychologists. Overview. Coding v. button clicking. Hello, nice to meet you. Variables Introduction Matlab for Psychologists Matlab is a language Simple rules for grammar Learn by using them There are many different ways to do each task Don t start from scratch - build on what other people

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

MATLAB Fundamentals. Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University

MATLAB Fundamentals. Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University MATLAB Fundamentals Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University Reference: 1. Applied Numerical Methods with MATLAB for Engineers, Chapter 2 &

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

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

To see what directory your work is stored in, and the directory in which Matlab will look for files, type

To see what directory your work is stored in, and the directory in which Matlab will look for files, type Matlab Tutorial For Machine Dynamics, here s what you ll need to do: 1. Solve n equations in n unknowns (as in analytical velocity and acceleration calculations) - in Matlab, this is done using matrix

More information

MATLAB Introduction To Engineering for ECE Topics Covered: 1. Creating Script Files (.m files) 2. Using the Real Time Debugger

MATLAB Introduction To Engineering for ECE Topics Covered: 1. Creating Script Files (.m files) 2. Using the Real Time Debugger 25.108 Introduction To Engineering for ECE Topics Covered: 1. Creating Script Files (.m files) 2. Using the Real Time Debugger SCRIPT FILE 77-78 A script file is a sequence of MATLAB commands, called a

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

Matlab Tutorial: Basics

Matlab Tutorial: Basics Matlab Tutorial: Basics Topics: opening matlab m-files general syntax plotting function files loops GETTING HELP Matlab is a program which allows you to manipulate, analyze and visualize data. MATLAB allows

More information

Some elements for Matlab programming

Some elements for Matlab programming Some elements for Matlab programming Nathalie Thomas 2018 2019 Matlab, which stands for the abbreviation of MATrix LABoratory, is one of the most popular language for scientic computation. The classical

More information

Image Processing CS 6640 : An Introduction to MATLAB Basics Bo Wang and Avantika Vardhan

Image Processing CS 6640 : An Introduction to MATLAB Basics Bo Wang and Avantika Vardhan Image Processing CS 6640 : An Introduction to MATLAB Basics Bo Wang and Avantika Vardhan August 29, 2014 1 Getting Started with MATLAB 1.1 Resources 1) CADE Lab: Matlab is installed on all the CADE lab

More information

MATLAB Modul 4. Introduction

MATLAB Modul 4. Introduction MATLAB Modul 4 Introduction to Computational Science: Modeling and Simulation for the Sciences, 2 nd Edition Angela B. Shiflet and George W. Shiflet Wofford College 2014 by Princeton University Press Introduction

More information

MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras

MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras Module No. #01 Lecture No. #1.1 Introduction to MATLAB programming

More information

Introduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis

Introduction to Matlab. Summer School CEA-EDF-INRIA 2011 of Numerical Analysis Introduction to Matlab 1 Outline What is Matlab? Matlab desktop & interface Scalar variables Vectors and matrices Exercise 1 Booleans Control structures File organization User defined functions Exercise

More information

MATLAB Tutorial. 1. The MATLAB Windows. 2. The Command Windows. 3. Simple scalar or number operations

MATLAB Tutorial. 1. The MATLAB Windows. 2. The Command Windows. 3. Simple scalar or number operations MATLAB Tutorial The following tutorial has been compiled from several resources including the online Help menu of MATLAB. It contains a list of commands that will be directly helpful for understanding

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

Machine Learning for Pre-emptive Identification of Performance Problems in UNIX Servers Helen Cunningham

Machine Learning for Pre-emptive Identification of Performance Problems in UNIX Servers Helen Cunningham Final Report for cs229: Machine Learning for Pre-emptive Identification of Performance Problems in UNIX Servers Helen Cunningham Abstract. The goal of this work is to use machine learning to understand

More information