How to program with Matlab (PART 1/3)

Size: px
Start display at page:

Download "How to program with Matlab (PART 1/3)"

Transcription

1 Programming course 1 09/12/2013 Martin SZINTE How to program with Matlab (PART 1/3) Plan 0. Setup of Matlab. 1. Matlab: the software interface. - Command window - Command history - Section help - Current directory - Workspace - Editor - Set Path 2. Rules and conventions of the programming language of Matlab. - Variables - Vector and matrix - Indexing or subscripts - Calculation - Relational and logical operators - Two other possible structures - Flow controls - Creating a function - Programming conventions 3. Basic graphs with Matlab. - Plot - Subplot - Barplot et histograms 0. Setup of Matlab Matlab is multi-platform software existing for any types of operating systems (OS: Mac, PC 32 bits, PC 64 bits, Linux). You are kindly invited to setup a version corresponding to your OS for example by asking the administrator of your laboratory or of your University. Be careful to setup the software corresponding to the specificity of your computer, setup either the 64 or 32 bits of Matlab. If you encounter problems during the setup, feel free to ask me questions (martin.szinte@gmail.com).

2 Remark: You are certainly not the only one to encounter problems during the setup of Matlab, don t hesitate asking questions or checking on Internet if anyone has the same problem and maybe solutions. 1. Matlab: the software interface Matlab is a complex software, composed of several windows that you can arrange in size, position, and that you can make appear or disappear as desired you can then organize the software in function of your tastes and needs. I will describe in the following chapter the windows you might need. Command window: We will use this window to communicate to Matlab any simple codes that you do not want to save. 1+1 factor(24) cosd(90) cosd(0) This window will serve us for doing simple processing. This is also in this window that error message will be displayed (due to one or several errors in your codes or little programs). This error message will be essential for our progress in programming. cos(32,5) -> An error message appears in command window indicating that the function cos doesn t take two arguments. We will see soon what an argument is but for the moment, this example allow us to illustrate the type of error message that Matlab reports. Command history: As indicated by its name, this window allow us to find back the different codes typed earlier in the command window, that is the history of our actions

3 Advice: You can recover the last typed command using the keyboard up arrow when your cursor is in the command window. Help section: This section is certainly the reason why Matlab is today the most used programming software in Sciences. Indeed, Matlab possesses a highly developed database on a huge set of functions and toolboxes that it contains. Moreover Matlab integrates a powerful search engine as well as a complete online help database with tons of examples and codes to download. Therefore with more or less time any initiated user can learn how to use new functions and toolboxes, learning by himself/herself via this help section and its definitions and concrete examples. There are different ways to access the help of Matlab: 1. Button Help: you must click on the button? 2. Type help in the command window. 3. Type help + function name help cos => it gives you help on a specific à function such as cosinus. 4. Type a particular function, select it then using the secondary mouse button choose Help on selection. => If the function is a Matlab function (made by the firm), this manipulation will send you to the help navigator. If it is a home made function, the help navigator will send you to the initial comment you have type when the function was created (we will go back to that point when we will speak of the programming conventions to use when creating new functions). Help Navigator. - Useful section as you will generally found well-stated explanations. - Propose some definitions of concepts, courses on some points (as in statistics), syntax and concrete examples on functions. - In the case of a specific search, the help navigator frequently report a definition of the function. For example have a look at the function cos.

4 Advice: It could be useful to have a look at the end of the help navigator window where you will find the see also section. You will find others functions that might better correspond to your needs. Current directory/folder This window indicates the directory of reference in which Matlab executes the functions. It also is the directory where new pieces of code, new data tables or texts will be saved by default (via saving functions such as csvwrite). csvwrite('tab.csv',[ ]) The function csvwrite create CSV files, CSV for comma-separated values, which is a common format for saving numerical values. Here the code saves the values [ ] in a file called tab.csv, which will be stored in the current directory. Advice: We can easily modifies the current directory using the function cd cd C:/your file /tatata/tatati %(for PC) cd /your file/tatata/tatati %(for mac) Type help cd for more information. Workspace This window contains a description of all the variables typed in the command window or in a script. As suggested by its name, it is the working memory of the software. We will then use this window for example to check that a variable exists and that its value corresponds to the expected one. If you type cat = 32 in the command window, the new variable cat appears in the workspace, as well as its values, its minimum and maximum (note that using the secondary

5 mouse button you can select the variable information you want to display in the workspace window. Advice: It might be useful when a variable contains a lot of different values (lot of columns and rows) to visualize these in a table. By double-clicking on elements of the workspace, you can access to the array editor window. This window displays your variable as (for example) in Microsoft Excel. It is even possible to modify a value of the table and to enter new values (for example with copy/paste from a table in Microsoft Excel). Editor This last window allows us to create and edit.m files (and others). After clicking on the editor window, click File >> New > and choose M-File. An empty page appears in the editor window. Write on the page the following things: text = I just wrote my first program with Matlab ; disp(text) Now save your script File>>Save as, under the name start.m. That.m file will be saved in the current directory as explained previously. Now that your new script (or new little program) is saved, you can close and re-open it as desired. You can also execute the script by clicking on the green arrow in the editor or by pressing F5 on the keyboard). The script will then displayed in the command window: I just wrote my first program with Matlab Advice: Open a new.m file and put in it all the different lines of code that we will see and have seen so far. Name this file for example course_matlab_nb1.m. You will then have a record of all the things we have seen here in a single file from which you can easily execute the codes. You can then comment each code, using %. This simple letter will tell Matlab that the following is a comment and should not be executed.

6 Set Path In the section File you can find the sub-section Set path. When you click on Set path a window will appear that allows you to manage all functions and toolboxes path. Then, each time we will create a script (program without input nor output) or a function (program with input and output), we will need to specify its path so that Matlab executes it. For this purpose, you have 3 different solutions: 1. Change the current directory and put all your function and scripts in this directory, which will become then the default directory. 2. Add each directory of your functions and scripts using the set path window, and clicking on Add Folder or Add folder with sub folder and selecting your directory. 3. Use at the beginning of your codes the Matlab function addpath() and specify the directories for which you would like to create a path (for more information help addpath). Advice: If you use the solution 1 or 2, never called two programs with the same name. Indeed Matlab will choose one of the two functions (the latest recorded in the path) and it might then not be the one you want. The solution 3 is from far the best solution as the path is added every time you launch a program. With this solution you do not have to take up to date the path list. Also you will be able to launch your programs several months or years after their creation without the need to remember the important directories to add to the path before starting a program. 2. Rules and conventions of the programming language of Matlab Matlab uses a particular language so-called high level (to differentiate form the low level languages also called machine language), which is also a script language, meaning that it allows the avoidance of compiling the program (a long step that involve the transformation of a source code readable by human to a binary file executable by a machine).

7 Therefore a program made in Matlab is easily understandable and the learning of the language is far more rapid. A counterpart of this accessibility is that Matlab is slower than any other compiled language program as it needs to be interpreted every time it is launched. As any script language, Matlab language involves several rules and conventions allowing respectively the program to correctly works and the better understanding of a program when it is shared between different peoples. Indeed, it exists several ways of programming the same experience or the same analyses of data. The following course describes a way of doing it and one type of conventions. Feel free to modify the codes to fit your way of thinking and of programming. As soon as a program works the code behind doesn t matter. VARIABLES We will start here with the basis of programming with Matlab, which is the creation of variables. You can attribute a value to an element and store it in the working memory to be able to use it later in a calculation or another execution. For this purpose you should type for example: str1 = 'I have no clue of what I am currently doing' With this statement, we just said to the software to create a variable called str1, which is a list of characters (a string). Type now: a = 7 b = 5; a+b; a+b Question 1: What happens in the command window? What s the point of using a semi-colon? Without semi-colom, the command window returns the /value of a or the results of a+b. When the semi-colon is typed after the command, nothing is displayed in the command window.

8 The semi-colon allows us to avoid the display of all the calculations; nevertheless the calculations and creation of variables still occur even though nothing is printed in the command window. Type: c = a+b; c You can notice that c has for value the sum of a+b even if the results is not displayed first. Remark: Sometimes Matlab will be stuck during the execution of a calculation, even though nothing is printed in the command window (you will then see busy at the lower left corner of Matlab). Under such situation, you can stop the current calculation by pressing CTRL + C. Type now: who whos The function who returns a list of variable stored in the workspace. The same list is accessible directly in the workspace window. Question 2: What s the role of whos? Whos returns the same list of the workspace, but this time with more details (size of the variable, memory allocated and class of the variable). You can then notice that str1 is a char class, a, b, c are double class. Indeed in function of how we code these different variables (using quotation marks for str1 and nothing for the others), Matlab understands that str1 is a list of characters and attributes the then the class «char». a, b and c involve a number or the results of a calculation as values, Matlab attributes then the class «double» for double-precision floating point (one way of coding numbers in informatics). VECTOR ET MATRICES Vectors and matrices are the basis of Matlab programming, which is indeed called Matlab for MATrix LABoratory.

9 Whatever the type of data that you with to treat with Matlab, it will be necessary for you to think and to reason in terms of matrices of either one dimension (=vectors) or 2 or more dimensions (matrices). In order to create a vector you then need to type: rawvect1 = [1, 2, 3, 4, 5, 6]; rawvect2 = [1:6] ; Question3: What s the reason of using : when creating our new vector rawvect2? The notation rawvect2 = [1:6]; orders to Matlab to create a vector identical to rawvect1. Indeed in Matlab the two dots indicates until. We will then go from 1 until 6 and by default the steps will always be 1. Question4: How can we go from 1 to 6 by a different step than 1, for example by step of 2? rawvect3 = [1:2:6] ; In order to create a vector in column we can type: colvect1 = [1; 2; 3; 4; 5; 6]; colvect2 = rawvect1 We use then semi-colon to separate the different values. The apostrophe allow us to put the values in a single column. Question5: How can we create a variable with two columns or more? mat1 = [1, 2; 3, 4; 5, 6; 7, 8] mat2 = [1, 2, 3; 1, 2,3 ; 1, 2, 3 ; 1, 2, 3] mat3 = [1, 2, 3; 4, 5, 6 ; 7, 8, 9 ; 10, 11, 12]

10 INDEXING OR SUBSCRIPTS Each variable that we defined earlier (char, vectors and matrices) have a certain size corresponding to the number of rows and columns they are composed of. In order to access the size, type: size(mat1) size(str1) numel(str1) length(mat2) The function size() send back the number of rows and columns of a variable. To access one, several or all the elements of a variable, type: rawvect1(1) rawvect1(2) rawvect1([1 2 4]) rawvect1(1:2) rawvect1(:) In this situation the operator : means all. str1(10:end) For a matrix containing several lines and columns we will type: mat3(1,3) mat3(3,3) Question 6: What are the index numbers of the word «no» of the variable str1? str1 = 'I have no clue of what I am currently doing' If you type str1(8) you will notice that the n or the word no is the 8 th element of that variable and not the 6 th element. Indeed Matlab considers a space as a distinct element.

11 Question 7: How can we obtain the second line of the variable mat3? The 3 rd column? The two last lines? mat3(2,:) mat3(:,3) mat3(end-1:end,:) You can also modify one or several elements of a variable using the same indexing: mat3(1) = 2 mat3(:) = 2 str1 = ' I have no clue of what I am currently doing'; str1([3:15]) = 'have a clue'; Question 8: Why this last command doesn t work? You will have to replace each element by a new element, as there are 13 elements called, you should then type 13 elements in your new chain of characters. We will then for example: str1([3:16]) = ' have a clue '; (with two spaces, one before and one after the text! )

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

Module 1: Introduction RStudio

Module 1: Introduction RStudio Module 1: Introduction RStudio Contents Page(s) Installing R and RStudio Software for Social Network Analysis 1-2 Introduction to R Language/ Syntax 3 Welcome to RStudio 4-14 A. The 4 Panes 5 B. Calculator

More information

Introduction to Matlab for Econ 511b

Introduction to Matlab for Econ 511b Introduction to Matlab for Econ 511b I. Introduction Jinhui Bai January 20, 2004 Matlab means Matrix Laboratory. From the name you can see that it is a matrix programming language. Matlab includes both

More information

Lab: Supplying Inputs to Programs

Lab: Supplying Inputs to Programs Steven Zeil May 25, 2013 Contents 1 Running the Program 2 2 Supplying Standard Input 4 3 Command Line Parameters 4 1 In this lab, we will look at some of the different ways that basic I/O information can

More information

ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah)

ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah) Introduction ELEC4042 Signal Processing 2 MATLAB Review (prepared by A/Prof Ambikairajah) MATLAB is a powerful mathematical language that is used in most engineering companies today. Its strength lies

More information

CITS2401 Computer Analysis & Visualisation

CITS2401 Computer Analysis & Visualisation FACULTY OF ENGINEERING, COMPUTING AND MATHEMATICS CITS2401 Computer Analysis & Visualisation SCHOOL OF COMPUTER SCIENCE AND SOFTWARE ENGINEERING Topic 3 Introduction to Matlab Material from MATLAB for

More information

You just told Matlab to create two strings of letters 'I have no idea what I m doing' and to name those strings str1 and str2.

You just told Matlab to create two strings of letters 'I have no idea what I m doing' and to name those strings str1 and str2. Chapter 2: Strings and Vectors str1 = 'this is all new to me' str2='i have no clue what I am doing' str1 = this is all new to me str2 = I have no clue what I am doing You just told Matlab to create two

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 for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia

Matlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia Matlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia The goal for this tutorial is to make sure that you understand a few key concepts related to programming, and that you know the basics

More information

ECE Lesson Plan - Class 1 Fall, 2001

ECE Lesson Plan - Class 1 Fall, 2001 ECE 201 - Lesson Plan - Class 1 Fall, 2001 Software Development Philosophy Matrix-based numeric computation - MATrix LABoratory High-level programming language - Programming data type specification not

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

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

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur Lecture 04 Demonstration 1 So, we have learned about how to run Java programs

More information

APPM 2460 Matlab Basics

APPM 2460 Matlab Basics APPM 2460 Matlab Basics 1 Introduction In this lab we ll get acquainted with the basics of Matlab. This will be review if you ve done any sort of programming before; the goal here is to get everyone on

More information

CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) First Name: Last Name: NetID:

CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28)   First Name: Last Name: NetID: CS 1110 SPRING 2016: GETTING STARTED (Jan 27-28) http://www.cs.cornell.edu/courses/cs1110/2016sp/labs/lab01/lab01.pdf First Name: Last Name: NetID: Goals. Learning a computer language is a lot like learning

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 COURSE FALL 2004 SESSION 1 GETTING STARTED. Christian Daude 1

MATLAB COURSE FALL 2004 SESSION 1 GETTING STARTED. Christian Daude 1 MATLAB COURSE FALL 2004 SESSION 1 GETTING STARTED Christian Daude 1 Introduction MATLAB is a software package designed to handle a broad range of mathematical needs one may encounter when doing scientific

More information

Computer Vision. Matlab

Computer Vision. Matlab Computer Vision Matlab A good choice for vision program development because Easy to do very rapid prototyping Quick to learn, and good documentation A good library of image processing functions Excellent

More information

An Introduction to MATLAB See Chapter 1 of Gilat

An Introduction to MATLAB See Chapter 1 of Gilat 1 An Introduction to MATLAB See Chapter 1 of Gilat Kipp Martin University of Chicago Booth School of Business January 25, 2012 Outline The MATLAB IDE MATLAB is an acronym for Matrix Laboratory. It was

More information

Getting To Know Matlab

Getting To Know Matlab Getting To Know Matlab The following worksheets will introduce Matlab to the new user. Please, be sure you really know each step of the lab you performed, even if you are asking a friend who has a better

More information

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain

Introduction to Matlab. By: Dr. Maher O. EL-Ghossain Introduction to Matlab By: Dr. Maher O. EL-Ghossain Outline: q What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control

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

General Information. There are certain MATLAB features you should be aware of before you begin working with MATLAB.

General Information. There are certain MATLAB features you should be aware of before you begin working with MATLAB. Introduction to MATLAB 1 General Information Once you initiate the MATLAB software, you will see the MATLAB logo appear and then the MATLAB prompt >>. The prompt >> indicates that MATLAB is awaiting a

More information

Chris Simpkins (Georgia Tech) CS 2316 Data Manipulation for Engineers Python Overview 1 / 9

Chris Simpkins (Georgia Tech) CS 2316 Data Manipulation for Engineers Python Overview 1 / 9 http://xkcd.com/353/ Chris Simpkins (Georgia Tech) CS 2316 Data Manipulation for Engineers Python Overview 1 / 9 Python Python is a general-purpose programming language, meaning you can write any kind

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

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB The Desktop When you start MATLAB, the desktop appears, containing tools (graphical user interfaces) for managing files, variables, and applications associated with MATLAB. The following

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

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

A Basic Guide to Using Matlab in Econ 201FS

A Basic Guide to Using Matlab in Econ 201FS A Basic Guide to Using Matlab in Econ 201FS Matthew Rognlie February 1, 2010 Contents 1 Finding Matlab 2 2 Getting Started 2 3 Basic Data Manipulation 3 4 Plotting and Finding Returns 4 4.1 Basic Price

More information

CS/NEUR125 Brains, Minds, and Machines. Due: Wednesday, March 8

CS/NEUR125 Brains, Minds, and Machines. Due: Wednesday, March 8 CS/NEUR125 Brains, Minds, and Machines Lab 6: Inferring Location from Hippocampal Place Cells Due: Wednesday, March 8 This lab explores how place cells in the hippocampus encode the location of an animal

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

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

ENGR 1181 MATLAB 05: Input and Output

ENGR 1181 MATLAB 05: Input and Output ENGR 1181 MATLAB 05: Input and Output Learning Objectives 1. Create a basic program that can be used over and over or given to another person to use 2. Demonstrate proper use of the input command, which

More information

CS1110 Lab 1 (Jan 27-28, 2015)

CS1110 Lab 1 (Jan 27-28, 2015) CS1110 Lab 1 (Jan 27-28, 2015) First Name: Last Name: NetID: Completing this lab assignment is very important and you must have a CS 1110 course consultant tell CMS that you did the work. (Correctness

More information

Introduction to Scientific Computing with Matlab

Introduction to Scientific Computing with Matlab UNIVERSITY OF WATERLOO Introduction to Scientific Computing with Matlab SAW Training Course R. William Lewis Computing Consultant Client Services Information Systems & Technology 2007 Table of Contents

More information

This book is about using Visual Basic for Applications (VBA), which is a

This book is about using Visual Basic for Applications (VBA), which is a In This Chapter Describing Access Discovering VBA Seeing where VBA lurks Understanding how VBA works Chapter 1 Where VBA Fits In This book is about using Visual Basic for Applications (VBA), which is a

More information

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet. Mr G s Java Jive #2: Yo! Our First Program With this handout you ll write your first program, which we ll call Yo. Programs, Classes, and Objects, Oh My! People regularly refer to Java as a language that

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

Arduino IDE Friday, 26 October 2018

Arduino IDE Friday, 26 October 2018 Arduino IDE Friday, 26 October 2018 12:38 PM Looking Under The Hood Of The Arduino IDE FIND THE ARDUINO IDE DOWNLOAD First, jump on the internet with your favorite browser, and navigate to www.arduino.cc.

More information

MATLAB. Devon Cormack and James Staley

MATLAB. Devon Cormack and James Staley MATLAB Devon Cormack and James Staley MATrix LABoratory Originally developed in 1970s as a FORTRAN wrapper, later rewritten in C Designed for the purpose of high-level numerical computation, visualization,

More information

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. Lesson 2 VARIABLES Aim Understanding how computer programs store values, and how they are accessed and used in computer programs. WHAT ARE VARIABLES? When you input data (i.e. information) into a computer

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

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

Bioinformatics? Reads, assembly, annotation, comparative genomics and a bit of phylogeny.

Bioinformatics? Reads, assembly, annotation, comparative genomics and a bit of phylogeny. Bioinformatics? Reads, assembly, annotation, comparative genomics and a bit of phylogeny stefano.gaiarsa@unimi.it Linux and the command line PART 1 Survival kit for the bash environment Purpose of the

More information

I OFFICE TAB... 1 RIBBONS & GROUPS... 2 OTHER SCREEN PARTS... 4 APPLICATION SPECIFICATIONS... 5 THE BASICS...

I OFFICE TAB... 1 RIBBONS & GROUPS... 2 OTHER SCREEN PARTS... 4 APPLICATION SPECIFICATIONS... 5 THE BASICS... EXCEL 2010 BASICS Microsoft Excel I OFFICE TAB... 1 RIBBONS & GROUPS... 2 OTHER SCREEN PARTS... 4 APPLICATION SPECIFICATIONS... 5 THE BASICS... 6 The Mouse... 6 What Are Worksheets?... 6 What is a Workbook?...

More information

MATLAB Part 1. Introduction

MATLAB Part 1. Introduction MATLAB Part 1 Introduction MATLAB is problem solving environment which provides engineers and scientists an easy-to-use platform for a wide range of computational problems. In general, it is useful for

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

Why use MATLAB? Mathematcal computations. Used a lot for problem solving. Statistical Analysis (e.g., mean, min) Visualisation (1D-3D)

Why use MATLAB? Mathematcal computations. Used a lot for problem solving. Statistical Analysis (e.g., mean, min) Visualisation (1D-3D) MATLAB(motivation) Why use MATLAB? Mathematcal computations Used a lot for problem solving Statistical Analysis (e.g., mean, min) Visualisation (1D-3D) Signal processing (Fourier transform, etc.) Image

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

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

Python Programming Exercises 1

Python Programming Exercises 1 Python Programming Exercises 1 Notes: throughout these exercises >>> preceeds code that should be typed directly into the Python interpreter. To get the most out of these exercises, don t just follow them

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

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday

More information

John's Tutorial on Everyday Mathcad (Version 9/2/09) Mathcad is not the specialist's ultimate mathematical simulator

John's Tutorial on Everyday Mathcad (Version 9/2/09) Mathcad is not the specialist's ultimate mathematical simulator John's Tutorial on Everyday Mathcad (Version 9/2/09) Mathcad isn't: Mathcad is not the specialist's ultimate mathematical simulator Applied mathematicians may prefer the power of Mathematica Complex programs

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

Computer Concepts for Beginners

Computer Concepts for Beginners Computer Concepts for Beginners Greetings Hi, my name is Tony & we re about to take a big plunge into the computer world! For some of us, this might be the first time we re actually using our computers,

More information

Lab 1: Getting started with R and RStudio Questions? or

Lab 1: Getting started with R and RStudio Questions? or Lab 1: Getting started with R and RStudio Questions? david.montwe@ualberta.ca or isaacren@ualberta.ca 1. Installing R and RStudio To install R, go to https://cran.r-project.org/ and click on the Download

More information

2 Getting Started. Getting Started (v1.8.6) 3/5/2007

2 Getting Started. Getting Started (v1.8.6) 3/5/2007 2 Getting Started Java will be used in the examples in this section; however, the information applies to all supported languages for which you have installed a compiler (e.g., Ada, C, C++, Java) unless

More information

Thursday, February 16, More C++ and root

Thursday, February 16, More C++ and root More C++ and root Today s Lecture Series of topics from C++ Example of thinking though a problem Useful physics classes in ROOT Functions by this point you are used to the syntax of a function pass by

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

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming

Topics. Hardware and Software. Introduction. Main Memory. The CPU 9/21/2014. Introduction to Computers and Programming Topics C H A P T E R 1 Introduction to Computers and Programming Introduction Hardware and Software How Computers Store Data Using Python Introduction Computers can be programmed Designed to do any job

More information

Engineering Innovation Center MATLAB Basics

Engineering Innovation Center MATLAB Basics Engineering Innovation Center MATLAB Basics MATLAB Short for MATrix LABoratory Both a programming language and the interface Designed to deal with large sets of data and analysis Allows matrix manipulations,

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Weichung Wang 2003 NCTS-NSF Workshop on Differential Equations, Surface Theory, and Mathematical Visualization NCTS, Hsinchu, February 13, 2003 DE, ST, MV Workshop Matlab 1 Main

More information

Formulas and Functions

Formulas and Functions Conventions used in this document: Keyboard keys that must be pressed will be shown as Enter or Ctrl. Controls to be activated with the mouse will be shown as Start button > Settings > System > About.

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display Facilities Flow Control Using of M-File Writing User

More information

Tutorial 1: Unix Basics

Tutorial 1: Unix Basics Tutorial 1: Unix Basics To log in to your ece account, enter your ece username and password in the space provided in the login screen. Note that when you type your password, nothing will show up in the

More information

Chapter 1 Introduction

Chapter 1 Introduction Chapter 1 Introduction Hi! Welcome to my beginners guide to C++. If you are starting to program for the first time, I hope that you find the chapters I have written useful. C++ is an excellent language

More information

The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below.

The first thing we ll need is some numbers. I m going to use the set of times and drug concentration levels in a patient s bloodstream given below. Graphing in Excel featuring Excel 2007 1 A spreadsheet can be a powerful tool for analyzing and graphing data, but it works completely differently from the graphing calculator that you re used to. If you

More information

Chapter 1: An Overview of MATLAB

Chapter 1: An Overview of MATLAB Chapter 1: An Overview of MATLAB MATLAB is: A high-level language and interactive environment for numerical computation, visualization, and programming MATLAB can: Be used as a calculator, easily create

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

LAB 2 VECTORS AND MATRICES

LAB 2 VECTORS AND MATRICES EN001-4: Intro to Computational Design Tufts University, Department of Computer Science Prof. Soha Hassoun LAB 2 VECTORS AND MATRICES 1.1 Background Overview of data types Programming languages distinguish

More information

Digital Image Processing

Digital Image Processing Digital Image Processing Introduction to MATLAB Hanan Hardan 1 Background on MATLAB (Definition) MATLAB is a high-performance language for technical computing. The name MATLAB is an interactive system

More information

Fundamentals of Python: First Programs. Chapter 4: Strings and Text Files

Fundamentals of Python: First Programs. Chapter 4: Strings and Text Files Fundamentals of Python: First Programs Chapter 4: Strings and Text Files Objectives After completing this chapter, you will be able to Access individual characters in a string Retrieve a substring from

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

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

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

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Will Fox 25 September, 2006 Contents: 1) Interacting with Matlab 2) Arrays, aka Vectors 3) Thinking in Matlab vectorized indexing 4) Thinking in Matlab vectorized math 5) Thinking

More information

This is a book about using Visual Basic for Applications (VBA), which is a

This is a book about using Visual Basic for Applications (VBA), which is a 01b_574116 ch01.qxd 7/27/04 9:04 PM Page 9 Chapter 1 Where VBA Fits In In This Chapter Describing Access Discovering VBA Seeing where VBA lurks Understanding how VBA works This is a book about using Visual

More information

Introduction to Stata - Session 1

Introduction to Stata - Session 1 Introduction to Stata - Session 1 Simon, Hong based on Andrea Papini ECON 3150/4150, UiO January 15, 2018 1 / 33 Preparation Before we start Sit in teams of two Download the file auto.dta from the course

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

Microsoft Office 365 includes the entire Office Suite (Word, Excel, PowerPoint, Access, Publisher, Lync, Outlook, etc ) and an OneDrive account.

Microsoft Office 365 includes the entire Office Suite (Word, Excel, PowerPoint, Access, Publisher, Lync, Outlook, etc ) and an OneDrive account. Microsoft Office 365 Contents What is Office 365?... 2 What is OneDrive?... 2 What if you already have a Microsoft Account?... 2 Download Office for FREE... 3 How to Access OneDrive... 4 Office Online...

More information

Introduction to Mathcad

Introduction to Mathcad University of Wyoming ESIG Computer Lab April 2, 2005 Preface The Mathcad environment offers a blend of computation, visualization, symbolic manipulation and documentation to provide a "self-documenting"

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #43. Multidimensional Arrays

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #43. Multidimensional Arrays Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #43 Multidimensional Arrays In this video will look at multi-dimensional arrays. (Refer Slide Time: 00:03) In

More information

Variables are used to store data (numbers, letters, etc) in MATLAB. There are a few rules that must be followed when creating variables in MATLAB:

Variables are used to store data (numbers, letters, etc) in MATLAB. There are a few rules that must be followed when creating variables in MATLAB: Contents VARIABLES... 1 Storing Numerical Data... 2 Limits on Numerical Data... 6 Storing Character Strings... 8 Logical Variables... 9 MATLAB S BUILT-IN VARIABLES AND FUNCTIONS... 9 GETTING HELP IN MATLAB...

More information

Reference Guide. Adding a Generic File Store - Importing From a Local or Network ShipWorks Page 1 of 21

Reference Guide. Adding a Generic File Store - Importing From a Local or Network ShipWorks Page 1 of 21 Reference Guide Adding a Generic File Store - Importing From a Local or Network Folder Page 1 of 21 Adding a Generic File Store TABLE OF CONTENTS Background First Things First The Process Creating the

More information

Formulas, LookUp Tables and PivotTables Prepared for Aero Controlex

Formulas, LookUp Tables and PivotTables Prepared for Aero Controlex Basic Topics: Formulas, LookUp Tables and PivotTables Prepared for Aero Controlex Review ribbon terminology such as tabs, groups and commands Navigate a worksheet, workbook, and multiple workbooks Prepare

More information

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple

More information

Getting Started with Amicus Document Assembly

Getting Started with Amicus Document Assembly Getting Started with Amicus Document Assembly How great would it be to automatically create legal documents with just a few mouse clicks? We re going to show you how to do exactly that and how to get started

More information

Dr Richard Greenaway

Dr Richard Greenaway SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 3 Creating, Organising & Processing Data Dr Richard Greenaway 3 Creating, Organising & Processing Data In this Workshop the matrix type is introduced

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

MATLAB BASICS. M Files. Objectives

MATLAB BASICS. M Files. Objectives Objectives MATLAB BASICS 1. What is MATLAB and why has it been selected to be the tool of choice for DIP? 2. What programming environment does MATLAB offer? 3. What are M-files? 4. What is the difference

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

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

Computer Project: Getting Started with MATLAB

Computer Project: Getting Started with MATLAB Computer Project: Getting Started with MATLAB Name Purpose: To learn to create matrices and use various MATLAB commands. Examples here can be useful for reference later. MATLAB functions: [ ] : ; + - *

More information

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */

Language Basics. /* The NUMBER GAME - User tries to guess a number between 1 and 10 */ /* Generate a random number between 1 and 10 */ Overview Language Basics This chapter describes the basic elements of Rexx. It discusses the simple components that make up the language. These include script structure, elements of the language, operators,

More information

Course contents. Overview: Goodbye, calculator. Lesson 1: Get started. Lesson 2: Use cell references. Lesson 3: Simplify formulas by using functions

Course contents. Overview: Goodbye, calculator. Lesson 1: Get started. Lesson 2: Use cell references. Lesson 3: Simplify formulas by using functions Course contents Overview: Goodbye, calculator Lesson 1: Get started Lesson 2: Use cell references Lesson 3: Simplify formulas by using functions Overview: Goodbye, calculator Excel is great for working

More information

EL2310 Scientific Programming

EL2310 Scientific Programming (pronobis@kth.se) Overview Overview Wrap Up More on Scripts and Functions Basic Programming Lecture 2 Lecture 3 Lecture 4 Wrap Up Last time Loading data from file: load( filename ) Graphical input and

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB MATLAB stands for MATrix LABoratory. Originally written by Cleve Moler for college linear algebra courses, MATLAB has evolved into the premier software for linear algebra computations

More information

Dr Richard Greenaway

Dr Richard Greenaway SCHOOL OF PHYSICS, ASTRONOMY & MATHEMATICS 4PAM1008 MATLAB 2 Basic MATLAB Operation Dr Richard Greenaway 2 Basic MATLAB Operation 2.1 Overview 2.1.1 The Command Line In this Workshop you will learn how

More information

TUTORIAL MATLAB OPTIMIZATION TOOLBOX

TUTORIAL MATLAB OPTIMIZATION TOOLBOX TUTORIAL MATLAB OPTIMIZATION TOOLBOX INTRODUCTION MATLAB is a technical computing environment for high performance numeric computation and visualization. MATLAB integrates numerical analysis, matrix computation,

More information