Introduction to MATLAB Fall Bruno Abreu Calfa Department of Chemical Engineering Carnegie Mellon University

Size: px
Start display at page:

Download "Introduction to MATLAB Fall Bruno Abreu Calfa Department of Chemical Engineering Carnegie Mellon University"

Transcription

1 Introduction to MATLAB Fall 2014 Bruno Abreu Calfa Department of Chemical Engineering Carnegie Mellon University 1

2 What is MATLAB? Main MATLAB windows Simple calcula9ons Easy plo<ng with ezplot MATLAB BASICS 2

3 Matrix Laboratory What is MATLAB? Everything in MATLAB is a matrix Enhanced by toolboxes (functions for specimic applications) Optimization Statistics Bioinformatics Signal Processing Finance Widely used in industry and academia. Getting help: MATLAB Help, Google, books 3

4 Main Window 4

5 MATLAB as a Calculator Basic mathematical operators >> >> 2*3 + 4 >> 4/3-3/4 + 2^3 >> 4.2/ Use parentheses to enforce precedence >> 2*(3 + 4) >> 4.2/( ) >> 15/((2 + 3)*(4-1)) >> 2ˆ(3/2) 5

6 Easy Plo<ng with ezplot Plot simple func9ons with the command ezplot Example >> ezplot('x^2') Set limits on the horizontal axis >> ezplot('exp(-0.5*t)*sin(3*t)',[0 10]) Plo<ng implicit func9ons >> ezplot('x^2 + y^2-1',[-2 2]) >> axis equal 6

7 Graphical Solu9on to Linear Equa9ons Solve the following system graphically Rewrite it as follows Plot two implicit func9ons >> hold all >> ezplot('2*x1 + 3*x2-6') >> ezplot('4*x1 + 9*x2-15') >> hold off 7

8 Scalars, vectors, matrices DEFINING VARIABLES 8

9 DeMining Variables (I/II) Use the = sign for assignment >> a = 1 % Scalar variable 'a' stores the value 1 >> % This is a comment and is ignored by MATLAB >> b = -5.2; % ; at the end of a command avoids displaying the result on Command Window >> v1 = [1 2 3] % Row vector or 1-by-3 matrix >> v2 = [1,2,3] % Same as v1 >> v3 = [4;5;6] % Column vector or 3-by-1 matrix >> v1 + v3 % Error! Matrix dimensions must match! >> v1 + v3.' % OK. Transpose v3 to become 1-by-3 >> 2*v1 % Element-wise multiplication 9

10 DeMining Variables (II/II) >> m1 = [1 2 3; 4 5 6] % 2-by-3 matrix >> m2 = [4 5 6; 1 2 3] % Another 2-by-3 matrix >> m3 = m1*m2 % Error! Cannot multiply m1 and m2 >> m3 = m1.'*m2 % OK. Transpose m1 to 3-by-2, then multiply by m2. Store result in variable m3. >> 0.5*m1 % Element-wise multiplication Some useful func9ons >> m = ; >> fprintf('mass flowrate = %.2f kg/s', m) >> v = zeros(10,1) % 10-by-1 matrix full of zeros >> m = zeros(5) % 5-by-5 matrix full of zeros 10

11 MATLAB Quiz How do you use ezplot to graph? (a) ezplot('2x^2y + 4xy - 5xy^2-6') (b) (c) ezplot('2*x^2*y + 4*x*y - 5*x*y^2-6') ezplot('2*x^2*y + 4*x*y - 5*x*y^2') How do you define the matrix? (a) [2 1 0; 0-3 4] (b) [2 1; 0-3; 0 4] (c) [2 0; 1-3; 0 4] What is the solu9on to [3 5 2; 1 0 1] * [1 0; 2 0]? (a) Error (b) [13 0; 1 0] (c) [7 0; 2 0] 11

12 Everyone knows A\b SOLVING LINEAR EQUATIONS 12

13 Basics Given matrix A and vector b, solve for vector of unknowns x General idea In prac9ce, NEVER invert A and then mul9ply by b. More efficient and numerically stable methods (06-262). Applica9on: Linear material balances 13

14 Solving Ax = b in MATLAB Define matrix A and vector b Use the backslash operator \ to solve for x x = A\b Example >> A = [2 3; 4 9] >> b = [6; 15] >> x = A\b % Solution = [1.5; 1] 14

15 Sample Exam II: Problem 3 Flowsheet of the process (pure W) 100 kg/hr 15% S 85% W Boiler 80% S 20% W 60% S 40% W 15

16 Sample Exam II: Problem 3 (pure W) 100 kg/hr 15% S 85% W Boiler 80% S 20% W 60% S 40% W Calculate total amount of water driven off in the boiler. I. Overall solids balance II. Overall balance III. Mixer Overall: Solids: In MATLAB: >> A = [1 1; ] >> b = [25; 15] >> x = A\b 16

17 Sample Exam II: Problem 3' Unknown composi9on of stream leaving boiler. Addi9onal specifica9on: bypass stream flowrate = 10 kg/hr. Solve for all flows. Flowsheet of the process (pure W) 100 kg/hr 15% S 85% W Boiler 60% S 40% W 17

18 Sample Exam II: Problem 3' Hint: write all balances in terms of component flowrates. 100 kg/hr 15 kg/hr S 85 kg/hr W Boiler 60% S 40% W 10 kg/hr Degree of freedom analysis: 9 variables (component flowrates) Need to write 9 independent equa9ons 18

19 Sample Exam II: Problem 3' 100 kg/hr 15 kg/hr S 85 kg/hr W Boiler 60% S 40% W 10 kg/hr I. Outlet specification II. Splitter III. Boiler inlet composition (2) (1) (3) IV. Bypass stream composition V. Boiler (5) VI. Mixer (7) (4) (6) (8) VII. Bypass specification (9) 19

20 Sample Exam II: Problem 3' System of equa9ons in matrix form (1) (2) (3) (4) (5) (6) (7) (8) (9) In MATLAB Enter A and b (use the spreadsheet tool to fill in the nonzero elements of A and b) Solve for x >> x = A\b 20

21 Ethanol Production: Block Diagram Produc9on of ethanol from ethylene and water. µ 51 Feed (given) C 2 H 4 H 2 O C 2 H 6 O Biegler, L. T., Grossmann, I. E., Westerberg, A. W. (1997). Systematic Methods of Chemical Process Design. Prentice Hall. 21

22 Linear Material Balances Component material balances for ethylene (inlet of ethylene μ 01 and split frac9ons for separators are given). 11 equations 11 unknowns 22

23 Solving System of Linear Equations System in matrix form In MATLAB Define A and b Execute A\b 23

24 Gaussian Elimination: Basics The opera9on A\b may perform Gaussian Elimina9on (GE). There are a few varia9ons of GE (with complete or par9al pivo9ng). We will cover the pure GE algorithm. Objec9ve: perform elementary row opera9ons that make the A matrix upper triangular. Apply same opera9ons to vector b. Elementary row opera9ons Interchanging two rows or columns Adding a mul9ple of one row or column to another Mul9plying any row or column by a nonzero element Easier to explain with an example. Addi9onal reading: hdp:// of- linear- equa9ons.html zeros Upper Triangular Matrix 24

25 Gaussian Elimination: Example Convert to augmented matrix equation Elementary row operations: 25

26 Gaussian Elimination: Example Restoring original system: Back-substitution step: Row 3: Row 2: Row 1: 26

27 Reduced Row Echelon Form (RREF) If GE con9nues further to make the original matrix A the iden9ty matrix, then the augmented matrix is said to be in the RREF. For computa9onal reasons, when solving systems of linear equa9ons, it is some9mes preferable to stop row opera9ons before the matrix is completely reduced. RREF of the previous example: In MATLAB, rref func9on. >> A = [1 1 1; 4 3 4; 9 3 4] >> b = [3; 8; 7] >> Ab = [A b] >> rref(ab) 27

28 Using Editor Window CREATING MATLAB SCRIPTS 28

29 Editor Window

30 Creating a Script Type your code Save file (M- file) Click on Run See results on Command Window Publishing features (generate HTML, PDF etc.) Look it up for more details (other tutorials, Google etc.) 30

31 Scripting Example Using the colon (:) operator. start:stride:end t = -3:3; y = sin(t); figure plot(t,y) Decrease the stride from 1 (default) to 0.1. t = -3:0.1:3; y = sin(t); figure plot(t,y) title('plot of sine') xlabel('t') ylabel('y') See file Demo_Script.m for more examples. 31

32 Sample Exam II: Problem 3' Unknown composi9on of stream leaving boiler. Addi9onal specifica9on: bypass stream flowrate. Plot water flowrate afer boiler for different values of bypass flowrate (e.g, from 1 kg/hr to 10 kg/hr). Flowsheet of the process (pure W) 100 kg/hr 15% S 85% W Boiler 60% S 40% W 32

33 Sample Exam II: Problem 3' Hint: write all balances in terms of component flowrates. 100 kg/hr 15 kg/hr S 85 kg/hr W Boiler 60% S 40% W 1, 2,, 10 kg/hr Degree of freedom analysis: 9 variables (component flowrates) Need to write 9 independent equa9ons 33

34 Sample Exam II: Problem 3' 100 kg/hr 15 kg/hr S 85 kg/hr W Boiler 60% S 40% W p kg/hr I. Outlet specification II. Splitter III. Boiler inlet composition (2) (1) (3) IV. Bypass stream composition V. Boiler (5) VI. Mixer (7) (4) (6) (8) VII. Bypass specification (9) 34

35 Sample Exam II: Problem 3' System of equa9ons in matrix form (1) (2) (3) (4) (5) (6) (7) (8) (9) In MATLAB Enter A and b (use the spreadsheet tool to fill in the nonzero elements of A and b). Enter any number for p (e.g., 0). Write script to solve system for different values of p and then create a plot. 35

36 Sample Exam II: Problem 3' MATLAB script bprates = 1:10; waterrate = zeros(size(bprates)); for i = 1:length(bprates) b(end) = bprates(i); x = A\b; waterrate(i) = x(5); end figure plot(bprates,waterrate) xlabel('bypass Rate (kg/hr)','fontsize',16) ylabel('water Rate after Boiler (kg/hr)','fontsize',16) 36

37 Sample Exam II: Problem 3' Solu9on plot 37

38 plot, scatter, and bar commands MORE PLOTTING 38

39 General Usage Many functions for plotting ezplot, plot, scatter, loglog, semilogx, semilogy, surf, surfc, mesh, meshc Typical syntax: command(data1,data2,...,['prop1name',prop1value,...]) Formatting properties and values are described in the Help: 2D plots: lineseries properties 3D plots: surface properties 39

40 plot Command x = linspace(0,2*pi); y = sin(x); figure plot(x,y); x = linspace(0,2*pi); y = sin(x); figure plot(x,y,'color,'red'); title('plot of sin(x)'); xlabel('x'); ylabel('y'); 40

41 plot and scatter Commands Multiple plots on same Migure using hold all and hold off x = [0.5; 1.0; 1.5; 2.0; 2.5]; y = [0.135; 0.165; 0.195; 0.207; 0.223]; yp = *x ; figure hold all scatter(x,y,300,'fill') plot(x,yp,'linewidth',5) hold off xlabel('x','fontsize',24) ylabel('y','fontsize',24) leg = legend('data','linear Model','location','northwest'); set(leg,'fontsize',24) 41

42 bar Command x = [ ]; y = [ ]; figure bar(x,y) 42

43 Additional Help Two- part tutorial given at CMU (with exercises and solu9ons) hdp:// MATLABTutorials.html Prof. John Kitchin s MATLAB blog hdp://matlab.cheme.cmu.edu/ 43

Exercise Set Decide whether each matrix below is an elementary matrix. (a) (b) (c) (d) Answer:

Exercise Set Decide whether each matrix below is an elementary matrix. (a) (b) (c) (d) Answer: Understand the relationships between statements that are equivalent to the invertibility of a square matrix (Theorem 1.5.3). Use the inversion algorithm to find the inverse of an invertible matrix. Express

More information

MATH 423 Linear Algebra II Lecture 17: Reduced row echelon form (continued). Determinant of a matrix.

MATH 423 Linear Algebra II Lecture 17: Reduced row echelon form (continued). Determinant of a matrix. MATH 423 Linear Algebra II Lecture 17: Reduced row echelon form (continued). Determinant of a matrix. Row echelon form A matrix is said to be in the row echelon form if the leading entries shift to the

More information

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

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

More information

10/26/ Solving Systems of Linear Equations Using Matrices. Objectives. Matrices

10/26/ Solving Systems of Linear Equations Using Matrices. Objectives. Matrices 6.1 Solving Systems of Linear Equations Using Matrices Objectives Write the augmented matrix for a linear system. Perform matrix row operations. Use matrices and Gaussian elimination to solve systems.

More information

Section 3.1 Gaussian Elimination Method (GEM) Key terms

Section 3.1 Gaussian Elimination Method (GEM) Key terms Section 3.1 Gaussian Elimination Method (GEM) Key terms Rectangular systems Consistent system & Inconsistent systems Rank Types of solution sets RREF Upper triangular form & back substitution Nonsingular

More information

Introduction to MatLab. Introduction to MatLab K. Craig 1

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

More information

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

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

More information

Solving Systems Using Row Operations 1 Name

Solving Systems Using Row Operations 1 Name The three usual methods of solving a system of equations are graphing, elimination, and substitution. While these methods are excellent, they can be difficult to use when dealing with three or more variables.

More information

An Introduction to Numerical Methods

An Introduction to Numerical Methods An Introduction to Numerical Methods Using MATLAB Khyruddin Akbar Ansari, Ph.D., P.E. Bonni Dichone, Ph.D. SDC P U B L I C AT I O N S Better Textbooks. Lower Prices. www.sdcpublications.com Powered by

More information

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

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

More information

Here is a quick introduction to Matlab and a couple of its symbolic and control functions.

Here is a quick introduction to Matlab and a couple of its symbolic and control functions. Some Matlab 1 Here is a quick introduction to Matlab and a couple of its symbolic and control functions. Matlab is an interpreted language. When you enter a command in the Command window, the line is executed

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

For example, the system. 22 may be represented by the augmented matrix

For example, the system. 22 may be represented by the augmented matrix Matrix Solutions to Linear Systems A matrix is a rectangular array of elements. o An array is a systematic arrangement of numbers or symbols in rows and columns. Matrices (the plural of matrix) may be

More information

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

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

More information

Introduc)on to Matlab

Introduc)on to Matlab Introduc)on to Matlab Marcus Kaiser (based on lecture notes form Vince Adams and Syed Bilal Ul Haq ) MATLAB MATrix LABoratory (started as interac)ve interface to Fortran rou)nes) Powerful, extensible,

More information

Colorado State University Department of Mechanical Engineering. MECH Laboratory Exercise #1 Introduction to MATLAB

Colorado State University Department of Mechanical Engineering. MECH Laboratory Exercise #1 Introduction to MATLAB Colorado State University Department of Mechanical Engineering MECH 417 - Laboratory Exercise #1 Introduction to MATLAB Contents 1) Vectors and Matrices... 2 2) Polynomials... 3 3) Plotting and Printing...

More information

Introduction in MATLAB (TSRT04)

Introduction in MATLAB (TSRT04) VT2 2019 Division of Communication Systems Department of Electrical Engineering (ISY) Linköping University, Sweden www.commsys.isy.liu.se/en/student/kurser/tsrt04 About the Course MATLAB Basics Vectors

More information

INTRODUCTION TO NUMERICAL ANALYSIS

INTRODUCTION TO NUMERICAL ANALYSIS INTRODUCTION TO NUMERICAL ANALYSIS Cho, Hyoung Kyu Department of Nuclear Engineering Seoul National University 0. MATLAB USAGE 1. Background MATLAB MATrix LABoratory Mathematical computations, modeling

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

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

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

More information

An Introduction to MATLAB II

An Introduction to MATLAB II Lab of COMP 319 An Introduction to MATLAB II Lab tutor : Gene Yu Zhao Mailbox: csyuzhao@comp.polyu.edu.hk or genexinvivian@gmail.com Lab 2: 16th Sep, 2013 1 Outline of Lab 2 Review of Lab 1 Matrix in Matlab

More information

MatLab Project # 1 Due IN TUTORIAL Wednesday October 30

MatLab Project # 1 Due IN TUTORIAL Wednesday October 30 Mathematics 110 University of Victoria Fall 2013 MatLab Project # 1 Due IN TUTORIAL Wednesday October 30 Name ID V00 Section A0 Tutorial T0 Instructions: After completing this project, copy and paste your

More information

MATLAB: Introduction Part 1

MATLAB: Introduction Part 1 MATLAB: Introduction Part 1 Bruno Abreu Calfa Last Update: August 9, 2011 Contents 1 MATLAB as a Calculator 1 2 MATLAB Classes 3 3 1-D Arrays (Vectors) 5 4 2-D Arrays (Matrices) 6 5 Element-wise Operations

More information

2. Plotting in MATLAB

2. Plotting in MATLAB 2. Plotting in MATLAB MATLAB provides several methods for plotting the graphs of functions and more general curves. The easiest to use is what we will call EZ plotting, since it uses the command ezplot

More information

INTRODUCTION TO MATLAB PLOTTING WITH MATLAB

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

More information

The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development

The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Chapter 7 Graphics Learning outcomes Label your plots Create different

More information

x = 12 x = 12 1x = 16

x = 12 x = 12 1x = 16 2.2 - The Inverse of a Matrix We've seen how to add matrices, multiply them by scalars, subtract them, and multiply one matrix by another. The question naturally arises: Can we divide one matrix by another?

More information

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

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

More information

EXTENSION. a 1 b 1 c 1 d 1. Rows l a 2 b 2 c 2 d 2. a 3 x b 3 y c 3 z d 3. This system can be written in an abbreviated form as

EXTENSION. a 1 b 1 c 1 d 1. Rows l a 2 b 2 c 2 d 2. a 3 x b 3 y c 3 z d 3. This system can be written in an abbreviated form as EXTENSION Using Matrix Row Operations to Solve Systems The elimination method used to solve systems introduced in the previous section can be streamlined into a systematic method by using matrices (singular:

More information

Lab 1 Intro to MATLAB and FreeMat

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

More information

MATLAB Guide to Fibonacci Numbers

MATLAB Guide to Fibonacci Numbers MATLAB Guide to Fibonacci Numbers and the Golden Ratio A Simplified Approach Peter I. Kattan Petra Books www.petrabooks.com Peter I. Kattan, PhD Correspondence about this book may be sent to the author

More information

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

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

More information

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

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

More information

Select the Points You ll Use. Tech Assignment: Find a Quadratic Function for College Costs

Select the Points You ll Use. Tech Assignment: Find a Quadratic Function for College Costs In this technology assignment, you will find a quadratic function that passes through three of the points on each of the scatter plots you created in an earlier technology assignment. You will need the

More information

INTRODUCTION TO MATLAB (MATrix LABoratory): INTUITIVE APPROACH

INTRODUCTION TO MATLAB (MATrix LABoratory): INTUITIVE APPROACH M445 FALL 2012 INTRODUCTION TO MATLAB (MATrix LABoratory): INTUITIVE APPROACH MATLAB: Widely used in scientific community. Many powerful tools/constructs related to matrix manipulation, the corner stone

More information

Learning from Data Introduction to Matlab

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

More information

TUTORIAL 1 Introduction to Matrix Calculation using MATLAB TUTORIAL 1 INTRODUCTION TO MATRIX CALCULATION USING MATLAB

TUTORIAL 1 Introduction to Matrix Calculation using MATLAB TUTORIAL 1 INTRODUCTION TO MATRIX CALCULATION USING MATLAB INTRODUCTION TO MATRIX CALCULATION USING MATLAB Learning objectives Getting started with MATLAB and it s user interface Learn some of MATLAB s commands and syntaxes Get a simple introduction to use of

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

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

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB?

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB? Experiment 1: Introduction to MATLAB I Introduction MATLAB, which stands for Matrix Laboratory, is a very powerful program for performing numerical and symbolic calculations, and is widely used in science

More information

2. Use elementary row operations to rewrite the augmented matrix in a simpler form (i.e., one whose solutions are easy to find).

2. Use elementary row operations to rewrite the augmented matrix in a simpler form (i.e., one whose solutions are easy to find). Section. Gaussian Elimination Our main focus in this section is on a detailed discussion of a method for solving systems of equations. In the last section, we saw that the general procedure for solving

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

Purpose of the lecture MATLAB MATLAB

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

More information

University of Alberta

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

More information

Number of Regions An Introduction to the TI-Nspire CAS Student Worksheet Created by Melissa Sutherland, State University of New York at Geneseo

Number of Regions An Introduction to the TI-Nspire CAS Student Worksheet Created by Melissa Sutherland, State University of New York at Geneseo 1 Name Number of Regions An Introduction to the TI-Nspire CAS Student Worksheet Created by Melissa Sutherland, State University of New York at Geneseo Below you will find copies of the notes provided on

More information

Introduction to MATLAB Practical 1

Introduction to MATLAB Practical 1 Introduction to MATLAB Practical 1 Daniel Carrera November 2016 1 Introduction I believe that the best way to learn Matlab is hands on, and I tried to design this practical that way. I assume no prior

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

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

Mechanical Engineering Department Second Year (2015)

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

More information

MATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix.

MATLAB Tutorial. Mohammad Motamed 1. August 28, generates a 3 3 matrix. MATLAB Tutorial 1 1 Department of Mathematics and Statistics, The University of New Mexico, Albuquerque, NM 87131 August 28, 2016 Contents: 1. Scalars, Vectors, Matrices... 1 2. Built-in variables, functions,

More information

Matlab Tutorial: Basics

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

More information

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

Introduction to Matlab

Introduction to Matlab Introduction to Matlab By:Mohammad Sadeghi *Dr. Sajid Gul Khawaja Slides has been used partially to prepare this presentation Outline: What is Matlab? Matlab Screen Basic functions Variables, matrix, indexing

More information

Introduction to MATLAB

Introduction to MATLAB Introduction to MATLAB Econ 8305 Fall 2015 Hang Zhou The George Washington University Overview 1 Before Getting Started 2 Vector and Matrix Basic Scalar Calculation Matrix Arithmetic Operation Some Useful

More information

Introduction to Matlab for Engineers

Introduction to Matlab for Engineers Introduction to Matlab for Engineers Instructor: Thai Nhan Math 111, Ohlone, Spring 2016 Introduction to Matlab for Engineers Ohlone, Spring 2016 1/19 Today s lecture 1. The subplot command 2. Logarithmic

More information

Monday, 12 November 12. Matrices

Monday, 12 November 12. Matrices Matrices Matrices Matrices are convenient way of storing multiple quantities or functions They are stored in a table like structure where each element will contain a numeric value that can be the result

More information

Identity Matrix: >> eye(3) ans = Matrix of Ones: >> ones(2,3) ans =

Identity Matrix: >> eye(3) ans = Matrix of Ones: >> ones(2,3) ans = Very Basic MATLAB Peter J. Olver January, 2009 Matrices: Type your matrix as follows: Use space or, to separate entries, and ; or return after each row. >> [;5 0-3 6;; - 5 ] or >> [,5,6,-9;5,0,-3,6;7,8,5,0;-,,5,]

More information

What is Matlab? A software environment for interactive numerical computations

What is Matlab? A software environment for interactive numerical computations What is Matlab? A software environment for interactive numerical computations Examples: Matrix computations and linear algebra Solving nonlinear equations Numerical solution of differential equations Mathematical

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

Exploration Assignment #1. (Linear Systems)

Exploration Assignment #1. (Linear Systems) Math 0280 Introduction to Matrices and Linear Algebra Exploration Assignment #1 (Linear Systems) Acknowledgment The MATLAB assignments for Math 0280 were developed by Jonathan Rubin with the help of Matthew

More information

C =

C = file:///c:/documents20and20settings/ravindra/desktop/html/exercis... 1 of 5 10/3/2008 3:17 PM Lab Exercise 2 - Matrices Hyd 510L, Fall, 2008, NM Tech Programmed by J.L. Wilson, Sept, 2008 Problem 2.1 Create

More information

hp calculators hp 39g+ & hp 39g/40g Using Matrices How are matrices stored? How do I solve a system of equations? Quick and easy roots of a polynomial

hp calculators hp 39g+ & hp 39g/40g Using Matrices How are matrices stored? How do I solve a system of equations? Quick and easy roots of a polynomial hp calculators hp 39g+ Using Matrices Using Matrices The purpose of this section of the tutorial is to cover the essentials of matrix manipulation, particularly in solving simultaneous equations. How are

More information

MATLAB QUICK START TUTORIAL

MATLAB QUICK START TUTORIAL MATLAB QUICK START TUTORIAL This tutorial is a brief introduction to MATLAB which is considered one of the most powerful languages of technical computing. In the following sections, the basic knowledge

More information

Maths for Signals and Systems Linear Algebra in Engineering. Some problems by Gilbert Strang

Maths for Signals and Systems Linear Algebra in Engineering. Some problems by Gilbert Strang Maths for Signals and Systems Linear Algebra in Engineering Some problems by Gilbert Strang Problems. Consider u, v, w to be non-zero vectors in R 7. These vectors span a vector space. What are the possible

More information

Basic Graphs. Dmitry Adamskiy 16 November 2011

Basic Graphs. Dmitry Adamskiy 16 November 2011 Basic Graphs Dmitry Adamskiy adamskiy@cs.rhul.ac.uk 16 November 211 1 Plot Function plot(x,y): plots vector Y versus vector X X and Y must have the same size: X = [x1, x2 xn] and Y = [y1, y2,, yn] Broken

More information

ECE 202 LAB 3 ADVANCED MATLAB

ECE 202 LAB 3 ADVANCED MATLAB Version 1.2 1 of 13 BEFORE YOU BEGIN PREREQUISITE LABS ECE 201 Labs EXPECTED KNOWLEDGE ECE 202 LAB 3 ADVANCED MATLAB Understanding of the Laplace transform and transfer functions EQUIPMENT Intel PC with

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Kristian Sandberg Department of Applied Mathematics University of Colorado Goal The goal with this worksheet is to give a brief introduction to the mathematical software Matlab.

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

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

Precalculus Notes: Unit 7 Systems of Equations and Matrices

Precalculus Notes: Unit 7 Systems of Equations and Matrices Date: 7.1, 7. Solving Systems of Equations: Graphing, Substitution, Elimination Syllabus Objectives: 8.1 The student will solve a given system of equations or system of inequalities. Solution of a System

More information

Math 7 Elementary Linear Algebra PLOTS and ROTATIONS

Math 7 Elementary Linear Algebra PLOTS and ROTATIONS Spring 2007 PLOTTING LINE SEGMENTS Math 7 Elementary Linear Algebra PLOTS and ROTATIONS Example 1: Suppose you wish to use MatLab to plot a line segment connecting two points in the xy-plane. Recall that

More information

Dr Richard Greenaway

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

More information

Introduction to MATLAB

Introduction to MATLAB ELG 3125 - Lab 1 Introduction to MATLAB TA: Chao Wang (cwang103@site.uottawa.ca) 2008 Fall ELG 3125 Signal and System Analysis P. 1 Do You Speak MATLAB? MATLAB - The Language of Technical Computing ELG

More information

Physics 326G Winter Class 2. In this class you will learn how to define and work with arrays or vectors.

Physics 326G Winter Class 2. In this class you will learn how to define and work with arrays or vectors. Physics 326G Winter 2008 Class 2 In this class you will learn how to define and work with arrays or vectors. Matlab is designed to work with arrays. An array is a list of numbers (or other things) arranged

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

GUI Alternatives. Syntax. Description. MATLAB Function Reference plot. 2-D line plot

GUI Alternatives. Syntax. Description. MATLAB Function Reference plot. 2-D line plot MATLAB Function Reference plot 2-D line plot GUI Alternatives Use the Plot Selector to graph selected variables in the Workspace Browser and the Plot Catalog, accessed from the Figure Palette. Directly

More information

2.0 MATLAB Fundamentals

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

More information

Linear Equations in Linear Algebra

Linear Equations in Linear Algebra 1 Linear Equations in Linear Algebra 1.2 Row Reduction and Echelon Forms ECHELON FORM A rectangular matrix is in echelon form (or row echelon form) if it has the following three properties: 1. All nonzero

More information

Graphics in MATLAB. Responsible teacher: Anatoliy Malyarenko. November 10, Abstract. Basic Plotting Commands

Graphics in MATLAB. Responsible teacher: Anatoliy Malyarenko. November 10, Abstract. Basic Plotting Commands Graphics in MATLAB Responsible teacher: Anatoliy Malyarenko November 10, 2003 Contents of the lecture: Two-dimensional graphics. Formatting graphs. Three-dimensional graphics. Specialised plots. Abstract

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

W1005 Intro to CS and Programming in MATLAB. Plo9ng & Visualiza?on. Fall 2014 Instructor: Ilia Vovsha. hgp://www.cs.columbia.

W1005 Intro to CS and Programming in MATLAB. Plo9ng & Visualiza?on. Fall 2014 Instructor: Ilia Vovsha. hgp://www.cs.columbia. W1005 Intro to CS and Programming in MATLAB Plo9ng & Visualiza?on Fall 2014 Instructor: Ilia Vovsha hgp://www.cs.columbia.edu/~vovsha/w1005 Outline Plots (2D) Plot proper?es Figures Plots (3D) 2 2D Plots

More information

Introduction to Matlab

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

More information

Using MATLAB, SIMULINK and Control System Toolbox

Using MATLAB, SIMULINK and Control System Toolbox Using MATLAB, SIMULINK and Control System Toolbox A practical approach Alberto Cavallo Roberto Setola Francesco Vasca Prentice Hall London New York Toronto Sydney Tokyo Singapore Madrid Mexico City Munich

More information

Solving Systems of Equations Using Matrices With the TI-83 or TI-84

Solving Systems of Equations Using Matrices With the TI-83 or TI-84 Solving Systems of Equations Using Matrices With the TI-83 or TI-84 Dimensions of a matrix: The dimensions of a matrix are the number of rows by the number of columns in the matrix. rows x columns *rows

More information

SF1901 Probability Theory and Statistics: Autumn 2016 Lab 0 for TCOMK

SF1901 Probability Theory and Statistics: Autumn 2016 Lab 0 for TCOMK Mathematical Statistics SF1901 Probability Theory and Statistics: Autumn 2016 Lab 0 for TCOMK 1 Preparation This computer exercise is a bit different from the other two, and has some overlap with computer

More information

INTRODUCTION TO MATLAB, SIMULINK, AND THE COMMUNICATION TOOLBOX

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

More information

Overview selected topic in 2552/2. Introduction to Matlab 2. Matlab: What is it + Why Use It? Writing Programs. Variables

Overview selected topic in 2552/2. Introduction to Matlab 2. Matlab: What is it + Why Use It? Writing Programs. Variables 203484 selected topic in transportation 2552/2 Introduction to Matlab 2 Overview Topic No#1 Prepared by Weerakaset Suanpaga 1 2 Matlab (Matrix Laboratory) 3/04/2008 Writing a program: Environment, m files,

More information

3. Replace any row by the sum of that row and a constant multiple of any other row.

3. Replace any row by the sum of that row and a constant multiple of any other row. Math Section. Section.: Solving Systems of Linear Equations Using Matrices As you may recall from College Algebra or Section., you can solve a system of linear equations in two variables easily by applying

More information

How to learn MATLAB? Some predefined variables

How to learn MATLAB? Some predefined variables ECE-S352 Lab 1 MATLAB Tutorial How to learn MATLAB? 1. MATLAB comes with good tutorial and detailed documents. a) Select MATLAB help from the MATLAB Help menu to open the help window. Follow MATLAB s Getting

More information

QUICK INTRODUCTION TO MATLAB PART I

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

More information

1. Register an account on: using your Oxford address

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

More information

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

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

More information

MATLAB is a multi-paradigm numerical computing environment fourth-generation programming language. A proprietary programming language developed by

MATLAB is a multi-paradigm numerical computing environment fourth-generation programming language. A proprietary programming language developed by 1 MATLAB is a multi-paradigm numerical computing environment fourth-generation programming language. A proprietary programming language developed by MathWorks In 2004, MATLAB had around one million users

More information

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

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

More information

Introduction to Matlab

Introduction to Matlab Introduction to Matlab Enrique Muñoz Ballester Dipartimento di Informatica via Bramante 65, 26013 Crema (CR), Italy enrique.munoz@unimi.it Contact Email: enrique.munoz@unimi.it Office: Room BT-43 Industrial,

More information

Matrix Inverse 2 ( 2) 1 = 2 1 2

Matrix Inverse 2 ( 2) 1 = 2 1 2 Name: Matrix Inverse For Scalars, we have what is called a multiplicative identity. This means that if we have a scalar number, call it r, then r multiplied by the multiplicative identity equals r. Without

More information

MATH 2000 Gauss-Jordan Elimination and the TI-83 [Underlined bold terms are defined in the glossary]

MATH 2000 Gauss-Jordan Elimination and the TI-83 [Underlined bold terms are defined in the glossary] x y z 0 0 3 4 5 MATH 000 Gauss-Jordan Elimination and the TI-3 [Underlined bold terms are defined in the glossary] 3z = A linear system such as x + 4y z = x + 5y z = can be solved algebraically using ordinary

More information

Introduction to Matlab. By: Hossein Hamooni Fall 2014

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

More information

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

BEGINNING MATLAB. R.K. Beatson Mathematics Department University of Canterbury. 2 Matlab as a simple matrix calculator 2

BEGINNING MATLAB. R.K. Beatson Mathematics Department University of Canterbury. 2 Matlab as a simple matrix calculator 2 BEGINNING MATLAB R.K. Beatson Mathematics Department University of Canterbury Contents 1 Getting started 1 2 Matlab as a simple matrix calculator 2 3 Repeated commands 4 4 Subscripting, rows, columns and

More information