MATLAB Part 2. This week we will look at techniques which will allow you to build powerful applications in MATLAB

Size: px
Start display at page:

Download "MATLAB Part 2. This week we will look at techniques which will allow you to build powerful applications in MATLAB"

Transcription

1 MATLAB Part 2 This week we will look at techniques which will allow you to build powerful applications in MATLAB Using M-files for calculations Decisions and loops Introduction to plotting data Start MATLAB and change the working directory to H: Open your workspace Week1.mat from last week. Go to the MATLAB command window and type whos and make sure you still have the Flows and Concs matrices from last week. Using M-files for calculations A computer program usually consists of a number of commands. Except for very small programs, these commands are divided into a series of files. This is to keep the program tidy and to allow it to be modified and used efficiently (just like any other filing system). For example, in Fortran 90, the files are.f90 files. In MATLAB these files are called M- files. There are two types script M-files and function M-files. Script M-files Script M-files are simply a series of lines of text which MATLAB interprets as commands. For example, a script which synthesises and saves the same type of random data that you did last week is shown below: Create a notepad file with this script and save it as rain.m in the working directory. Then run the script by typing the filename in the command window: >>rain Note that all calculated variables are displayed in the command window (unless you include a ; at the end of each line of the script).

2 Script exercise 1 Download (by right-clicking) the file LoadCalcS.M from the web-page and save it on your H:. This is a script M-file which performs the load calculations for the Charles River. Open it using the MATLAB Menu option File Open. MATLAB opens the file using its own M-file editor. You should see; % Multiplies an array of flows by an array of concentrations to obtain an % array of loading rates % unit conversion FlowsConverted = Flows * 24 * 3600; ConcsConverted = Concs / 1000; % calculate load at each source for each day Loads = FlowsConverted.* ConcsConverted; % total all sources for each day TotalLoads = sum(loads') In MATLAB (data files, M-files and the command window) the % sign at the start of a line means the line is a comment which is ignored when you execute your program. It is important to include comments so that everyone can understand your program. Run the script by typing the M-file name in the command window. If you receive a redtype error in the Command window, then check the following; Are matrices Flows and Concs in your workspace? If not, you will have to import them as they are essential for the calculation. Are Flows and Concs named exactly as that (remember MATLAB is case sensitive). Are Flows and Concs in the correct format (numeric matrices of 7 columns and 3 rows)? Have you saved LoadCalcS.M in the same folder as your Workspace? Note 1) only the TotalLoads are displayed in the command window (because of the use of the ; in the script) but all variables have been stored in the workspace, 2) the first two lines are recognised by Matlab as a help facility - try typing help LoadCalcS in the command window. Script exercise 2 In your matrix Loads (which was produced by the LoadCalcS script) you should have a total of 21 items of COD pollution load data. Write a script M-file which; Converts the matrix into a single column vector (revise from the help page Concatenation)

3 Calculates the maximum and minimum of the 21 items (use the max and min functions). Counts the number of items which are greater than 150kg/day (use the find and numel commands). TIPS: 1. Create a new M-file using the File menu, New, M-File and save it as LoadStats 2. Before writing the M-file, you can type your individual commands in the command window, to check that they work. 3. You can find out about the find and numel commands by typing help find and help numel in the command window. 4. The answer is MaxL = 943.5; MinL = 6.7; NumL = Ask a tutor if you need some help! Function M-files Function M-files are slightly different from scripts because inputs and/or output variables are specified in the first line of the M-file. Download (by right-clicking) the file LoadCalcF.M from the web-page and save it on your H:. Open it using the MATLAB Menu option File Open. This Function M-file performs the same calculations as the script you looked at previously. % Multiplies an array of flows by an array of concentrations to obtain an % array of loading rates function [Loads, TotalLoads] = LoadCalcF(Flows, Concs) % unit conversion FlowsConverted = Flows * 24 * 3600; ConcsConverted = Concs / 1000; % calculate load at each source for each day Loads = FlowsConverted.* ConcsConverted; % total all sources for each day TotalLoads = sum(loads'); Type in the MATLAB command window >>[Loads, TotalLoads] = LoadCalcF(Flows, Concs) MATLAB sends the input variables (Flows, Concs) to the Function M-file, does the calculations within the M-File and sends back the output variables [Loads, TotalLoads], which should be listed in the Command window.

4 Why use function M-files rather than script M-files? Often, scripts are adequate. But if you want to have maximum flexibility over inputs and outputs then functions can be better. For example, you could use a different set of inputs (Flows2, Concs2) and outputs [Loads2, TotalLoads2], and your function would still work. Try it by making up new Flows2 and Concs2 and re-running the function: >>Flows2 = Flows * 2 >>Concs2 = Concs * 2 >>[Loads2, TotalLoads2] = LoadCalcF(Flows2, Concs2) On the other hand, using the script, you would have to edit the script - not very convenient when you have many sets of input-output data to analyse, and not possible if you want to create user-friendly applications. Decisions and Loops Almost all computer programs used for engineering and hydrological purposes contain decisions and loops. For example, in a wastewater treatment plant there are usually gas sensors which give an alarm IF the gas concentration exceeds a safe level. Furthermore, the control system may have to continually LOOP through all the sensors in the plant checking for alarms. The MATLAB functions for making decisions are if, elseif and else and for loops, while or for. Using the MATLAB help index (see below) find and study the first Function Reference Pages entitled if and for. Then read the first help page describing the loop function while.

5 Example Sensor_alarm.m (on web-site) is a Function M-File which loops through a data matrix called Sensor_Data, which contains readings from a number of gas sensors (Number_of_S), and reports if the gas concentration found by the sensors is low (L), high (H) or critically high (C). Try to understand the significance of the for, if and else statements: function[warn] = Sensor_alarm(Sensor_Data, Crit_Levels, Number_of_S) LOOP for s = 1:Number_of_S if Sensor_Data(s) > Crit_Levels(s) Warn(s) = 'C'; elseif Sensor_Data(s) > Crit_Levels(s)/2 Warn(s) = 'H'; else Warn(s) = 'L'; end end D E C I S I O N For example, run the function using the following inputs: by typing >>Number_of_S=3 >>Crit_Levels=[ ] >>Sensor_Data=[ ] >>[Warn] = Sensor_alarm(Sensor_Data, Crit_Levels, Number_of_S) The output of the program =should be: Warn = CLH TIPS MATLAB is designed so that the need for loops is minimised. If you have used other programming languages such as Fortran or Visual Basic you will be used to using loops for calculations with arrays. In MATLAB you can usually use matrix functions instead. When using the while function, be careful to not to create an infinite loop, which MATLAB keeps going round and round without being able to finish. If this does happen, you can cancel the whole function by hitting Ctrl-C on your keyboard.

6 Exercise 4 This exercise will apply a while loop and a decision. It also introduces you to plotting data in MATLAB. A river flow routing model is, Q out (k) = a Q (k m) + b Q in out (k 1) where Q out (k) is the downstream flow at time k. Q out (k-1) is the downstream flow at time k-1 (one time-step before k). Q in (k-m) is the upstream flow at time k-m. m is an integer representing a time-delay (the time at which the output begins to respond to the input) which depends upon the properties of the river. a and b are parameters which also depend upon the properties of the river. This model can be used to forecast Q out at the downstream section of the river, and give warning of flooding. Note: 1) to use the model we need to know Q in at all times and have at least one initial value for Q out ; 2) the first forecast of Q out (k) that we can possibly make is at time m after the first measurement of Q in ; 3) We need to calibrate the model in order to find suitable values of the a and b parameters. The following plot shows the measured upstream (Abbeystead) flow and downstream flow (St Michael s) data for a flood on the River Wyre in Northern England. This data is contained within the textfile Wyre.txt which you can download from the web-site. Look at this file using Notepad. Note that the first line of text is preceded by % so that MATLAB will recognise it as a comment, and will not read it.

7 1. Create a matrix Pars which contains the parameters a, b. For now, assume that a = 1 and b = 1. >>Pars = [1 1] 2. Write a function M-file called Routing.M which, - reads the Wyre data text file - runs the model to estimate Q out as a function of Q in every hour for t = 3 to 30 hours. - plots a time-series of the forecast Q out, together with the data for Q out and the data for Q in, - gives a warning if the forecast flood exceeds 100m 3 /s Your only input variable is the matrix Pars. See TIPS and M-file on the next page. 3. Run the model a few times with different values of a and b so that the forecast Q out more closely matches the Q out data. TIPS: Create a new M-file using File New M-file. Save it as Routing You may copy the M-file on the next page. Run the model >> Routing(Pars) When you have finished, save your workspace as Week2.mat >> save Week2

8 Also, keep your Wyre.txt and Routing.M files you will use them next week.

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

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

7 Control Structures, Logical Statements

7 Control Structures, Logical Statements 7 Control Structures, Logical Statements 7.1 Logical Statements 1. Logical (true or false) statements comparing scalars or matrices can be evaluated in MATLAB. Two matrices of the same size may be compared,

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

An Introduction to MATLAB

An Introduction to MATLAB An Introduction to MATLAB Day 1 Simon Mitchell Simon.Mitchell@ucla.edu High level language Programing language and development environment Built-in development tools Numerical manipulation Plotting of

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab 1 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

Introduction to programming in MATLAB

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

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

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

Desktop Command window

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

More information

Homework #2: Introduction to Images Due 4 th Week of Spring 2018 at the start of lab CSE 7, Spring 2018

Homework #2: Introduction to Images Due 4 th Week of Spring 2018 at the start of lab CSE 7, Spring 2018 Homework #2: Introduction to Images Due 4 th Week of Spring 2018 at the start of lab CSE 7, Spring 2018 Before beginning this homework, create a new Notepad++ file in your cs7sxx home directory on ieng6

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

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

EL2310 Scientific Programming

EL2310 Scientific Programming Lecture 4: Programming in Matlab Yasemin Bekiroglu (yaseminb@kth.se) Florian Pokorny(fpokorny@kth.se) Overview Overview Lecture 4: Programming in Matlab Wrap Up More on Scripts and Functions Wrap Up Last

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

(excluding printing time)

(excluding printing time) Using e-mail and the Internet Level 1 8982-11-011 (IT-EMI 11) This paper must be returned with the candidate s work. Failure to do so will result in delay in processing the candidates scripts. Candidate

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

1. Below is an example 1D river reach model built in HEC-RAS and displayed in the HEC-RAS user interface:

1. Below is an example 1D river reach model built in HEC-RAS and displayed in the HEC-RAS user interface: How Do I Import HEC-RAS Cross-Section Data? Flood Modeller allows you to read in cross sections defined in HEC-RAS models, automatically converting them to Flood Modeller 1D cross sections. The procedure

More information

FOR LOOP. for <indexmin:indexstep:indexmax> {statements} end

FOR LOOP. for <indexmin:indexstep:indexmax> {statements} end FOR LOOP for {statements} Exercise: Define a vector z R 10 (= R 10 1 ) s.t. z j = 2 j for j = 1,...,10. Solution. Create a new script wiht the following instructions: for

More information

Introduction to Programming for Biology Research

Introduction to Programming for Biology Research Introduction to Programming for Biology Research Introduction to MATLAB: part I MATLAB Basics - The interface - Variables/arrays/matrices - Conditional statements - Loops (for and while) MATLAB: The

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

EGR 111 Functions and Relational Operators

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

More information

EGR 111 Functions and Relational Operators

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

More information

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

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing

SECTION 1: INTRODUCTION. ENGR 112 Introduction to Engineering Computing SECTION 1: INTRODUCTION ENGR 112 Introduction to Engineering Computing 2 Course Overview What is Programming? 3 Programming The implementation of algorithms in a particular computer programming language

More information

Chapter 1 Introduction to MATLAB

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

More information

Matlab 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

Computer lab 2 Course: Introduction to R for Biologists

Computer lab 2 Course: Introduction to R for Biologists Computer lab 2 Course: Introduction to R for Biologists April 23, 2012 1 Scripting As you have seen, you often want to run a sequence of commands several times, perhaps with small changes. An efficient

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

MATLAB An introductory tutorial

MATLAB An introductory tutorial MATLAB An introductory tutorial By Carin Nilsson Dept. of Physical Geography and Ecosystems Analysis (taken from the tutorials for course NGE604 Climate Systems) And Chantal Donnelly (Dept. of Water Resources

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

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

Programming 1. Script files. help cd Example:

Programming 1. Script files. help cd Example: Programming Until now we worked with Matlab interactively, executing simple statements line by line, often reentering the same sequences of commands. Alternatively, we can store the Matlab input commands

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

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

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

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

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

More information

EGR 111 Functions and Relational Operators

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

More information

This tutorial shows how to extract longitudinal profiles using ArcMap 10.1 and how to plot them with R, an open-source software.

This tutorial shows how to extract longitudinal profiles using ArcMap 10.1 and how to plot them with R, an open-source software. JESSE S. HILL 2013 UNC-CH This tutorial shows how to extract longitudinal profiles using ArcMap 10.1 and how to plot them with R, an open-source software. R is freely available at: cran.us.r-project.org/

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

Matlab Primer. Lecture 02a Optical Sciences 330 Physical Optics II William J. Dallas January 12, 2005

Matlab Primer. Lecture 02a Optical Sciences 330 Physical Optics II William J. Dallas January 12, 2005 Matlab Primer Lecture 02a Optical Sciences 330 Physical Optics II William J. Dallas January 12, 2005 Introduction The title MATLAB stands for Matrix Laboratory. This software package (from The Math Works,

More information

Short Version of Matlab Manual

Short Version of Matlab Manual Short Version of Matlab Manual This is an extract from the manual which was used in MA10126 in first year. Its purpose is to refamiliarise you with the matlab programming concepts. 1 Starting MATLAB 1.1.1.

More information

1) As a logical statement, is 1 considered true or false in MATLAB? Explain your answer.

1) As a logical statement, is 1 considered true or false in MATLAB? Explain your answer. ENGR 1181 Midterm 2+ Review Note: This practice material does not contain actual test questions or represent the format of the final. The first 20 questions should be completed WITHOUT using MATLAB. This

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

ECE 102 Engineering Computation

ECE 102 Engineering Computation ECE 102 Engineering Computation Phillip Wong MATLAB Loops for while break / continue Loops A loop changes the execution flow in a program. What happens in a loop? For each iteration of the loop, statements

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

CS 221 Lecture. Tuesday, 13 September 2011

CS 221 Lecture. Tuesday, 13 September 2011 CS 221 Lecture Tuesday, 13 September 2011 Today s Agenda 1. Announcements 2. Boolean Expressions and logic 3. MATLAB Fundamentals 1. Announcements First in-class quiz: Tuesday 4 October Lab quiz: Thursday

More information

Matlab Tutorial. Get familiar with MATLAB by using tutorials and demos found in MATLAB. You can click Start MATLAB Demos to start the help screen.

Matlab Tutorial. Get familiar with MATLAB by using tutorials and demos found in MATLAB. You can click Start MATLAB Demos to start the help screen. University of Illinois at Urbana-Champaign Department of Electrical and Computer Engineering ECE 298JA Fall 2015 Matlab Tutorial 1 Overview The goal of this tutorial is to help you get familiar with MATLAB

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

MATLAB GUIDE UMD PHYS401 SPRING 2011

MATLAB GUIDE UMD PHYS401 SPRING 2011 MATLAB GUIDE UMD PHYS401 SPRING 2011 Note that it is sometimes useful to add comments to your commands. You can do this with % : >> data=[3 5 9 6] %here is my comment data = 3 5 9 6 At any time you can

More information

MINIMAT TUTORIAL Joel Robbin June 92

MINIMAT TUTORIAL Joel Robbin June 92 MINIMAT TUTORIAL Joel Robbin June 92 The purpose of this tutorial is to give you a feeling for how MINIMAT interacts with the user and what it can do. The tutorial is not intended to be a definitive account

More information

Programming for Experimental Research. Flow Control

Programming for Experimental Research. Flow Control Programming for Experimental Research Flow Control FLOW CONTROL In a simple program, the commands are executed one after the other in the order they are typed. Many situations require more sophisticated

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

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

DgnAudit. 1. What is DgnAudit?

DgnAudit. 1. What is DgnAudit? 1 1. What is DgnAudit? DgnAudit is an MDL program developed by Australian Data Systems to assist MicroStation users in the complex task of documenting and finding design files. Search produces an audit

More information

Applied Matrix Theory - Math Summer 09 MATLAB Project 3 Created by Prof. Diego Maldonado and Prof. Virginia Naibo

Applied Matrix Theory - Math Summer 09 MATLAB Project 3 Created by Prof. Diego Maldonado and Prof. Virginia Naibo Applied Matrix Theory - Math 551 - Summer 09 MATLAB Project Created by Prof. Diego Maldonado and Prof. Virginia Naibo In this project you will be introduced to MATLAB programming. What you have to submit:

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

v Prerequisite Tutorials None Time minutes Required Components Hydrologic Models

v Prerequisite Tutorials None Time minutes Required Components Hydrologic Models v. 10.1 WMS 10.1 Tutorial Watershed Modeling Orange County Rational Method Build and run a rational method analysis based on methods in the Orange County (California) hydrology manual Objectives Completing

More information

Introduction to MATLAB LAB 1

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

More information

MATLAB Operators, control flow and scripting. Edited by Péter Vass

MATLAB Operators, control flow and scripting. Edited by Péter Vass MATLAB Operators, control flow and scripting Edited by Péter Vass Operators An operator is a symbol which is used for specifying some kind of operation to be executed. An operator is always the member

More information

AN INTRODUCTION TO MATLAB

AN INTRODUCTION TO MATLAB AN INTRODUCTION TO MATLAB 1 Introduction MATLAB is a powerful mathematical tool used for a number of engineering applications such as communication engineering, digital signal processing, control engineering,

More information

COMSTAT USER MANUAL (REVISED 2/ ) Written by Arne Heydorn

COMSTAT USER MANUAL (REVISED 2/ ) Written by Arne Heydorn COMSTAT USER MANUAL (REVISED 2/10-2000) Written by Arne Heydorn aheydorn1@gmail.com 1 COMSTAT is a program for quantification of three-dimensional biofilm structures. It analyzes stacks of images acquired

More information

Matlab Programming MET 164 1/24

Matlab Programming MET 164 1/24 Matlab Programming 1/24 2/24 What does MATLAB mean? Contraction of Matrix Laboratory Matrices are rectangular arrays of numerical values 7 3 6 2 1 9 4 4 8 4 1 5 7 2 1 3 What are the fundamental components

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. 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 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

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

Writing MATLAB Programs

Writing MATLAB Programs Outlines September 14, 2004 Outlines Part I: Review of Previous Lecture Part II: Review of Previous Lecture Outlines Part I: Review of Previous Lecture Part II: Control Structures If/Then/Else For Loops

More information

Lab 0a: Introduction to MATLAB

Lab 0a: Introduction to MATLAB http://www.comm.utoronto.ca/~dkundur/course/real-time-digital-signal-processing/ Page 1 of 1 Lab 0a: Introduction to MATLAB Professor Deepa Kundur Introduction and Background Welcome to your first real-time

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

D-BAUG Informatik I. Exercise session: week 5 HS 2018

D-BAUG Informatik I. Exercise session: week 5 HS 2018 1 D-BAUG Informatik I Exercise session: week 5 HS 2018 Homework 2 Questions? Matrix and Vector in Java 3 Vector v of length n: Matrix and Vector in Java 3 Vector v of length n: double[] v = new double[n];

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

Process Eye Professional. Recall

Process Eye Professional. Recall Process Eye Professional Recall Process Eye Professional Recall User Manual SP104010.101 August 2005 As part of our continuous product improvement policy, we are always pleased to receive your comments

More information

MATLAB/Octave Tutorial

MATLAB/Octave Tutorial University of Illinois at Urbana-Champaign Department of Electrical and Computer Engineering ECE 298JA Fall 2017 MATLAB/Octave Tutorial 1 Overview The goal of this tutorial is to help you get familiar

More information

Quick Guide Ver lite 26/10/16

Quick Guide Ver lite 26/10/16 SEPSIM Quick Guide Ver. 2.3.1 - lite 26/10/16 Revisions Version Date Description Ver. 2.1.7 - lite 17/07/07 First version release Ver. 2.2.6 - lite 10/09/14 Added "Open Loop" mode. Minor bug fixes Ver.

More information

Introduction to MATLAB

Introduction to MATLAB to MATLAB Spring 2019 to MATLAB Spring 2019 1 / 39 The Basics What is MATLAB? MATLAB Short for Matrix Laboratory matrix data structures are at the heart of programming in MATLAB We will consider arrays

More information

Introduction to MATLAB Programming. Chapter 3. Linguaggio Programmazione Matlab-Simulink (2017/2018)

Introduction to MATLAB Programming. Chapter 3. Linguaggio Programmazione Matlab-Simulink (2017/2018) Introduction to MATLAB Programming Chapter 3 Linguaggio Programmazione Matlab-Simulink (2017/2018) Algorithms An algorithm is the sequence of steps needed to solve a problem Top-down design approach to

More information

Introduction to MATLAB

Introduction to MATLAB Quick Start Tutorial Introduction to MATLAB Hans-Petter Halvorsen, M.Sc. What is MATLAB? MATLAB is a tool for technical computing, computation and visualization in an integrated environment. MATLAB is

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

CSE/NEUBEH 528 Homework 0: Introduction to Matlab

CSE/NEUBEH 528 Homework 0: Introduction to Matlab CSE/NEUBEH 528 Homework 0: Introduction to Matlab (Practice only: Do not turn in) Okay, let s begin! Open Matlab by double-clicking the Matlab icon (on MS Windows systems) or typing matlab at the prompt

More information

ENGR 253 LAB #1 - MATLAB Introduction

ENGR 253 LAB #1 - MATLAB Introduction ENGR 253 LAB #1 - MATLAB Introduction Objective Understanding and hands on experience with MATLAB with focus on Signal Processing. Resources Signals & Systems textbook by Oppenheim and Willsky Windows

More information

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices

Introduction to. The Help System. Variable and Memory Management. Matrices Generation. Interactive Calculations. Vectors and Matrices Introduction to Interactive Calculations Matlab is interactive, no need to declare variables >> 2+3*4/2 >> V = 50 >> V + 2 >> V Ans = 52 >> a=5e-3; b=1; a+b Most elementary functions and constants are

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

AEMLog Users Guide. Version 1.01

AEMLog Users Guide. Version 1.01 AEMLog Users Guide Version 1.01 INTRODUCTION...2 DOCUMENTATION...2 INSTALLING AEMLOG...4 AEMLOG QUICK REFERENCE...5 THE MAIN GRAPH SCREEN...5 MENU COMMANDS...6 File Menu...6 Graph Menu...7 Analysis Menu...8

More information

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB

MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB MAT 343 Laboratory 1 Matrix and Vector Computations in MATLAB In this laboratory session we will learn how to 1. Create matrices and vectors. 2. Manipulate matrices and create matrices of special types

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Introduction MATLAB is an interactive package for numerical analysis, matrix computation, control system design, and linear system analysis and design available on most CAEN platforms

More information

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

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

More information

Section 2 Getting Started

Section 2 Getting Started Section 2 Getting Started ECDL Section 2 Getting Started By the end of this section you should be able to: Start, restart and close down a device Log on and log off Windows Recognise and use the Desktop

More information

Hydrologic Modeling using HEC-HMS

Hydrologic Modeling using HEC-HMS Hydrologic Modeling using HEC-HMS CE 412/512 Spring 2017 Introduction The intent of this exercise is to introduce you to the structure and some of the functions of the HEC-Hydrologic Modeling System (HEC-HMS),

More information

Creating and Managing Surveys

Creating and Managing Surveys Creating and Managing Surveys May 2014 Survey Software Contents 1. INTRODUCTION 2 2. HOW TO ACCESS THE SURVEY SOFTWARE 3 The User Profile 3 3. GETTING STARTED ON A NEW SURVEY 5 4. FURTHER WORK ON SURVEY

More information

Files and File Management Scripts Logical Operations Conditional Statements

Files and File Management Scripts Logical Operations Conditional Statements Files and File Management Scripts Logical Operations Conditional Statements Files and File Management Matlab provides a group of commands to manage user files pwd: Print working directory displays the

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

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

Part I. Introduction to Linux

Part I. Introduction to Linux Part I Introduction to Linux 7 Chapter 1 Linux operating system Goal-of-the-Day Familiarisation with basic Linux commands and creation of data plots. 1.1 What is Linux? All astronomical data processing

More information

Tutorial Hydrodynamics in sewers

Tutorial Hydrodynamics in sewers Tutorial Hydrodynamics in sewers September 2007 3.9230.00 Tutorial Hydrodynamics in sewers September 2007 Tutorial Hydrodynamics in sewers 3.9230.00 September 2007 Contents 1 Tutorial Hydrodynamics in

More information

Isothermal Batch Reactor Modeling

Isothermal Batch Reactor Modeling Instructions for use of the tutorial: Download the compressed file Example1.zip and store it on a folder of your choice on your desktop, or in a location where you have rights to read and write. Open the

More information

MATLAB for Image Processing. April 2018 Rod Dockter

MATLAB for Image Processing. April 2018 Rod Dockter MATLAB for Image Processing April 2018 Rod Dockter Outline Introduction to MATLAB Basics & Examples Image Processing with MATLAB Basics & Examples What is MATLAB? MATLAB = Matrix Laboratory MATLAB is a

More information

MATLAB Demo. Preliminaries and Getting Started with Matlab

MATLAB Demo. Preliminaries and Getting Started with Matlab Math 250C Sakai submission Matlab Demo 1 Created by G. M. Wilson, revised 12/23/2015 Revised 09/05/2016 Revised 01/07/2017 MATLAB Demo In this lab, we will learn how to use the basic features of Matlab

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

WMS 10.0 Tutorial Watershed Modeling MODRAT Interface Schematic Build a MODRAT model by defining a hydrologic schematic

WMS 10.0 Tutorial Watershed Modeling MODRAT Interface Schematic Build a MODRAT model by defining a hydrologic schematic v. 10.0 WMS 10.0 Tutorial Watershed Modeling MODRAT Interface Schematic Build a MODRAT model by defining a hydrologic schematic Objectives This tutorial shows users how to define a basic MODRAT model using

More information