Appendix B BASIC MATRIX OPERATIONS IN PROC IML B.1 ASSIGNING SCALARS

Size: px
Start display at page:

Download "Appendix B BASIC MATRIX OPERATIONS IN PROC IML B.1 ASSIGNING SCALARS"

Transcription

1 Appendix B BASIC MATRIX OPERATIONS IN PROC IML B.1 ASSIGNING SCALARS Scalars can be viewed as 1 1 matrices and can be created using Proc IML by using the statement x¼scalar_value or x¼{scalar_value}. As an example, the statements x¼14.5 and x¼{14.5} are the same and both store the value 14.5 in x. We can also store character values as the commands name¼james and hello¼hello World illustrate. The stored values in the variables can easily be determined by using the print command in Proc IML. For example to view the values in the variables x, name, and hello use the command Print x name hello. B.2 CREATING MATRICES AND VECTORS As mentioned in Appendix A, it is easy to create matrices and vectors in Proc IML. The command A¼{2 4, 3 1} will create the matrix A ¼ Each row of the matrix is separated by a comma. That is, each row of the above command yields a row vector. For instance, the command A¼{ } creates the row vector A ¼ ½ Š. If we separate each entry in the row vector by a comma, we will get a columnvector. As an example, the command A¼{1,2,3,4} creates the column vector A ¼ Applied Econometrics Using the SAS Ò System, by Vivek B. Ajmani Copyright Ó 2009 John Wiley & Sons, Inc. 249

2 250 APPENDIX B BASIC MATRIX OPERATIONS IN PROC IML These commands can easily be extended to create matrices consisting of character elements. For example, the command A¼{a b, c d} will create the matrix A ¼ a b c d B.3 ELEMENTARY MATRIX OPERATIONS B.3.a Addition/Subtraction of Matrices For two conformable matrices, A and B, their sum can be computed by using the command C¼A þ B, where the sum is stored in C. Changing the addition to a subtraction yields the difference between the two matrices. B.3.b Product of Matrices For two conformable matrices, A and B, the element by element product of the twois givenby the command C¼A#B. For example, consider the two matrices A ¼ 1 2 and B ¼ The element by element product of these two is given by C ¼ The product of the two matrices is given by using the command C¼A*B. In the above example, the product is C ¼ The square of a matrix is given by either of the following commands C¼A##2 or C¼A*A. Of course, we can use these commands to raise a matrix to any power (assuming that the product is defined). B.3.c Kronecker Products The Kronecker product of two matrices A and B can be obtained by using the command A@B. For example, let A ¼ and B ¼ Then, the command C¼A@B will produce C ¼ B.3.d Inverses, Eigenvalues, and Eigenvectors As shown in Appendix A, the inverse of a square matrix A can be computed by using the command C¼inv(A). Eigenvalues and eigenvectors can be computed easily by using the commands C¼eigval(A) or C¼eigvec(A).

3 APPENDIX B BASIC MATRIX OPERATIONS IN PROC IML 251 B.4 COMPARISON OPERATORS The max(min) commands will search for the maximum(minimum) element of any matrix or vector. To use these commands, simply type C¼max(A) or C¼min(A). For two conformable matrices (of the same dimension), we can define the elementwise maximums and minimums. Consider matrices A and B, which were given in (Section B.3.b). The command C¼A<>B will find the elementwise maximum between the two matrices. In our example, this will yield C ¼ The command C¼A><B will yield the elementwise minimum between the two matrices. In our example, this is simply A. B.5 MATRIX-GENERATING FUNCTIONS B.5.a Identity Matrix The command Iden¼I(3) will create a 3 3 identity matrix. B.5.b The J Matrix This is a matrix of 1 s. The command J¼J(3,3) will create a 3 3 matrix of 1 s. This command can be modified to create a matrix of constants. For example, suppose that we want a 3 3 matrix of 2 s. We can modify the above command as follows J¼J(3,3,2). B.5.c Block Diagonal Matrices Often, we will have towork with block diagonal matrices. A block diagonal matrix can be created by using the command C¼block (A 1,A 2,...) where A 1,A 2...are matrices. For example, for the A and B matrices defined earlier, the block diagonal matrix C is given by C ¼ B.5.d Diagonal Matrices The identity matrix is a matrix with 1 s on the diagonal. It is easy to create any diagonal matrix in Proc IML. For instance, the command C¼diag({1 2 4}) will create the following diagonal matrix C ¼ Given a square matrix, the diag command can be used to extract the diagonal elements. For example, the command C¼diag({1 2,3 4}) will create the following matrix C ¼ B.6 SUBSET OF MATRICES Econometric analysis using Proc IML often involves extracting specific columns (or rows) of matrices. The command C¼A[,1] will extract the first column of the matrix A, and the command R¼A[1,] will extract the first row of the matrix A. B.7 SUBSCRIPT REDUCTION OPERATORS Proc IML can be used to easily calculatevarious row- and column-specific statistics of matrices. As an example, consider the 3 3 matrix defined by the command A¼{0 1 2, 5 4 3, 7 6 8}. Column sums of this matrix can be computed by using the command

4 252 APPENDIX B BASIC MATRIX OPERATIONS IN PROC IML Col_Sum¼A[ þ,]. Using this command yields a row vector Col_Sum with elements 12, 11, and 13. The row sums of this matrix can be computed by using the command Row_Sum¼A[, þ ]. We can also determine the maximum element in each column by using the command Col_Max¼A[<>,]. Using this command yields a row vector Col_Max with elements 7, 6, and 8. The command Row_Min¼A[,><] will yield the minimum of each row of the matrix. The column means can be calculated by using the command Col_Mean¼A[,]. Using this command, yields the row vector Col_Mean with elements 4, 3.67, and The command Col_Prod¼A[#,] results in a row vector Col_Prod that contains the product of the elements in each column. In our example, the result is a row vector with elements 0, 24, and 48. We can easily extend this command to calculate the sums of squares of each column. This is calculated by using the command Col_SSQ¼A[##,]. The result is a row vector Col_SSQ with elements 74, 53, and 77. B.8 THE DIAG AND VECDIAG COMMANDS The Proc IML Diag command create a diagonal matrix. For example, if A ¼ 1 3 ; 2 4 then the command B¼Diag(A) results in a diagonal matrix B whose diagonal elements are the diagonal elements of A. That is, B ¼ This command is useful when extracting the standard errors of regression coefficients from the diagonal elements of the variance covariance matrices. If a column vector consisting of the diagonal elements of A is desirable, then one can use the VecDiag function. As an example, the command B¼VecDiag(A) results in B ¼ 1 4 B.9 CONCATENATION OF MATRICES There are several instances wherewe have a need to concatenate matrices. A trivial case is wherewe need to append a column of 1s to a data matrix. Horizontal concatenation can be done by using jj, while vertical concatenation can be done by using ==. For example, consider the following matrices A ¼ and B ¼ The command AjjB gives the matrix whereas the command A==B gives the matrix ; B.10 CONTROL STATEMENTS Several Proc IML routines given in this book make use of control statements. For example, we made use of control statements when computing MLE estimates for the parameters. These statements were also used when computing estimates through iterative procedures.

5 DO-END Statement The statements following the DO statement are executed until a matching END statement is encountered. DO Iterative Statement The DO iterative statements take the form DO Index=start TO end; IML statements follow END; For example, the statements DO Index=1 to 5; Print Index; END; will print the value of INDEX for each iteration of the DO statement. The output will consist of the values of INDEX starting from 1 through 5. IF-THEN/ELSE Statement These statements can be used to impose restrictions or conditions on other statements. The IF part imposes the restriction and the THEN part executes the action to be taken if the restrictions are met. The ELSE portion of the statement execute the action for the alternative. For example, the statements IF MAX(A)<30 then print Good Data ; ELSE print Bad Data ; evaluate the matrix A. If the maximum element of the matrix is less than 30, then the statement Good Data is printed, else the statement Bad Data is printed. B.11 CALCULATING SUMMARY STATISTICS IN PROC IML Summary statistics on the numeric variables stored in matrices can be obtained in Proc IML by using the SUMMARY command. The summary statistics can be based on subgroups (e.g., Panel Data) and can be saved in matrices for later use. As an example, consider the cost of US airlines panel data set from Greene (2003). The data consist of 90 observations for six firms for The following SAS statements can be used to summarize the data by airline. The option opt(save) saves the summary statistics by airline. The statements will retrieve and save the summary statistics in matrices. The names of the matrices are identical to the names of the variables. The statement print LnC produces the means and standard deviations for the six airlines for the variable LnC. The first column contains the means, whereas the second column contains the standard deviations. We have found this command useful when programming the Hausman Taylor estimation method for panel data models. The resulting output is given in output B.1. proc import out=airline datafile="c\temp\airline" dbms=excel Replace; getnames=yes; run; Data airline; set airline; LnC=log(C); LnQ=Log(Q); LnPF=Log(PF); run; proc iml; use airline; summary var {LnC LnQ LnPF} class {i} stat{mean std} opt{save}; print LnC; run; APPENDIX B BASIC MATRIX OPERATIONS IN PROC IML 253

6 254 APPENDIX B BASIC MATRIX OPERATIONS IN PROC IML I Nobs Variable MEAN STD LNC LNQ LNPF LNC LNQ LNPF LNC LNQ LNPF LNC LNQ LNPF LNC LNQ LNPF LNC LNQ LNPF All 90 LNC LNQ LNPF LNC OUTPUT B.1. Summary statistics of three variables for each airline.

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

Statistical Programming in SAS. From Chapter 10 - Programming with matrices and vectors - IML

Statistical Programming in SAS. From Chapter 10 - Programming with matrices and vectors - IML Week 12 [30+ Nov.] Class Activities File: week-12-iml-prog-16nov08.doc Directory: \\Muserver2\USERS\B\\baileraj\Classes\sta402\handouts From Chapter 10 - Programming with matrices and vectors - IML 10.1:

More information

Chapter 1 Introduction to SAS/IML Software

Chapter 1 Introduction to SAS/IML Software Chapter 1 Introduction to SAS/IML Software Chapter Contents OVERVIEW................................... 7 SAS/IML SOFTWARE: AN OVERVIEW................... 7 AN INTRODUCTORY INTERACTIVE SESSION..............

More information

Lecture 2: Variables, Vectors and Matrices in MATLAB

Lecture 2: Variables, Vectors and Matrices in MATLAB Lecture 2: Variables, Vectors and Matrices in MATLAB Dr. Mohammed Hawa Electrical Engineering Department University of Jordan EE201: Computer Applications. See Textbook Chapter 1 and Chapter 2. Variables

More information

FreeMat Tutorial. 3x + 4y 2z = 5 2x 5y + z = 8 x x + 3y = -1 xx

FreeMat Tutorial. 3x + 4y 2z = 5 2x 5y + z = 8 x x + 3y = -1 xx 1 of 9 FreeMat Tutorial FreeMat is a general purpose matrix calculator. It allows you to enter matrices and then perform operations on them in the same way you would write the operations on paper. This

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

Computer Packet 1 Row Operations + Freemat

Computer Packet 1 Row Operations + Freemat Computer Packet 1 Row Operations + Freemat For this packet, you will use a website to do row operations, and then learn to use a general purpose matrix calculator called FreeMat. To reach the row operations

More information

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

D-Optimal Designs. Chapter 888. Introduction. D-Optimal Design Overview

D-Optimal Designs. Chapter 888. Introduction. D-Optimal Design Overview Chapter 888 Introduction This procedure generates D-optimal designs for multi-factor experiments with both quantitative and qualitative factors. The factors can have a mixed number of levels. For example,

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

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

Matrices. A Matrix (This one has 2 Rows and 3 Columns) To add two matrices: add the numbers in the matching positions:

Matrices. A Matrix (This one has 2 Rows and 3 Columns) To add two matrices: add the numbers in the matching positions: Matrices A Matrix is an array of numbers: We talk about one matrix, or several matrices. There are many things we can do with them... Adding A Matrix (This one has 2 Rows and 3 Columns) To add two matrices:

More information

Finite Math - J-term Homework. Section Inverse of a Square Matrix

Finite Math - J-term Homework. Section Inverse of a Square Matrix Section.5-77, 78, 79, 80 Finite Math - J-term 017 Lecture Notes - 1/19/017 Homework Section.6-9, 1, 1, 15, 17, 18, 1, 6, 9, 3, 37, 39, 1,, 5, 6, 55 Section 5.1-9, 11, 1, 13, 1, 17, 9, 30 Section.5 - Inverse

More information

A SAS/IML Primer. Appendix A. A.1 Overview of the SAS/IML Language. Contents

A SAS/IML Primer. Appendix A. A.1 Overview of the SAS/IML Language. Contents Appendix A A SAS/IML Primer Contents A.1 Overview of the SAS/IML Language..................... 325 A.2 SAS/IML Functions That Are Used in This Book............... 326 A.3 The PRINT Statement.............................

More information

PCOMP http://127.0.0.1:55825/help/topic/com.rsi.idl.doc.core/pcomp... IDL API Reference Guides > IDL Reference Guide > Part I: IDL Command Reference > Routines: P PCOMP Syntax Return Value Arguments Keywords

More information

0_PreCNotes17 18.notebook May 16, Chapter 12

0_PreCNotes17 18.notebook May 16, Chapter 12 Chapter 12 Notes BASIC MATRIX OPERATIONS Matrix (plural: Matrices) an n x m array of elements element a ij Example 1 a 21 = a 13 = Multiply Matrix by a Scalar Distribute scalar to all elements Addition

More information

Contents of SAS Programming Techniques

Contents of SAS Programming Techniques Contents of SAS Programming Techniques Chapter 1 About SAS 1.1 Introduction 1.1.1 SAS modules 1.1.2 SAS module classification 1.1.3 SAS features 1.1.4 Three levels of SAS techniques 1.1.5 Chapter goal

More information

MATLAB for Experimental Research. Fall 2018 Vectors, Matrices, Matrix Operations

MATLAB for Experimental Research. Fall 2018 Vectors, Matrices, Matrix Operations MATLAB for Experimental Research Fall 2018 Vectors, Matrices, Matrix Operations Matlab is more than a calculator! The array is a fundamental form that MATLAB uses to store and manipulate data. An array

More information

Basics. Bilkent University. CS554 Computer Vision Pinar Duygulu

Basics. Bilkent University. CS554 Computer Vision Pinar Duygulu 1 Basics CS 554 Computer Vision Pinar Duygulu Bilkent University 2 Outline Image Representation Review some basics of linear algebra and geometrical transformations Slides adapted from Octavia Camps, Penn

More information

GraphBLAS Mathematics - Provisional Release 1.0 -

GraphBLAS Mathematics - Provisional Release 1.0 - GraphBLAS Mathematics - Provisional Release 1.0 - Jeremy Kepner Generated on April 26, 2017 Contents 1 Introduction: Graphs as Matrices........................... 1 1.1 Adjacency Matrix: Undirected Graphs,

More information

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB MATLAB sessions: Laboratory MAT 75 Laboratory Matrix Computations and Programming in MATLAB In this laboratory session we will learn how to. Create and manipulate matrices and vectors.. Write simple programs

More information

A User Manual for the Multivariate MLE Tool. Before running the main multivariate program saved in the SAS file Part2-Main.sas,

A User Manual for the Multivariate MLE Tool. Before running the main multivariate program saved in the SAS file Part2-Main.sas, A User Manual for the Multivariate MLE Tool Before running the main multivariate program saved in the SAS file Part-Main.sas, the user must first compile the macros defined in the SAS file Part-Macros.sas

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

Getting Started with the SAS/IML Language

Getting Started with the SAS/IML Language Paper 144-2013 Getting Started with the SAS/IML Language Rick Wicklin, SAS Institute Inc. ABSTRACT Do you need a statistic that is not computed by any SAS procedure? Reach for the SAS/IML language! Many

More information

Matlab Tutorial, CDS

Matlab Tutorial, CDS 29 September 2006 Arrays Built-in variables Outline Operations Linear algebra Polynomials Scripts and data management Help: command window Elisa (see Franco next slide), Matlab Tutorial, i.e. >> CDS110-101

More information

Example Lecture 12: The Stiffness Method Prismatic Beams. Consider again the two span beam previously discussed and determine

Example Lecture 12: The Stiffness Method Prismatic Beams. Consider again the two span beam previously discussed and determine Example 1.1 Consider again the two span beam previously discussed and determine The shearing force M1 at end B of member B. The bending moment M at end B of member B. The shearing force M3 at end B of

More information

Lecture 5: Matrices. Dheeraj Kumar Singh 07CS1004 Teacher: Prof. Niloy Ganguly Department of Computer Science and Engineering IIT Kharagpur

Lecture 5: Matrices. Dheeraj Kumar Singh 07CS1004 Teacher: Prof. Niloy Ganguly Department of Computer Science and Engineering IIT Kharagpur Lecture 5: Matrices Dheeraj Kumar Singh 07CS1004 Teacher: Prof. Niloy Ganguly Department of Computer Science and Engineering IIT Kharagpur 29 th July, 2008 Types of Matrices Matrix Addition and Multiplication

More information

Stat 302 Statistical Software and Its Applications SAS: Interactive Matrix Language (IML)

Stat 302 Statistical Software and Its Applications SAS: Interactive Matrix Language (IML) Stat 302 Statistical Software and Its Applications SAS: Interactive Matrix Language (IML) Fritz Scholz Department of Statistics, University of Washington Winter Quarter 2015 March 4, 2015 2 SAS IML: Links

More information

II.Matrix. Creates matrix, takes a vector argument and turns it into a matrix matrix(data, nrow, ncol, byrow = F)

II.Matrix. Creates matrix, takes a vector argument and turns it into a matrix matrix(data, nrow, ncol, byrow = F) II.Matrix A matrix is a two dimensional array, it consists of elements of the same type and displayed in rectangular form. The first index denotes the row; the second index denotes the column of the specified

More information

Matrix algebra. Basics

Matrix algebra. Basics Matrix.1 Matrix algebra Matrix algebra is very prevalently used in Statistics because it provides representations of models and computations in a much simpler manner than without its use. The purpose of

More information

Introduction to MATLAB for Engineers, Third Edition

Introduction to MATLAB for Engineers, Third Edition PowerPoint to accompany Introduction to MATLAB for Engineers, Third Edition William J. Palm III Chapter 2 Numeric, Cell, and Structure Arrays Copyright 2010. The McGraw-Hill Companies, Inc. This work is

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

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

Chapter 18 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal.

Chapter 18 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal. Chapter 8 out of 7 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal 8 Matrices Definitions and Basic Operations Matrix algebra is also known

More information

Math 1B03/1ZC3 - Tutorial 3. Jan. 24th/28th, 2014

Math 1B03/1ZC3 - Tutorial 3. Jan. 24th/28th, 2014 Math 1B03/1ZC3 - Tutorial 3 Jan. 24th/28th, 2014 Tutorial Info: Website: http://ms.mcmaster.ca/ dedieula. Math Help Centre: Wednesdays 2:30-5:30pm. Email: dedieula@math.mcmaster.ca. Elementary Matrices

More information

CS Data Structures and Algorithm Analysis

CS Data Structures and Algorithm Analysis CS 483 - Data Structures and Algorithm Analysis Lecture VI: Chapter 5, part 2; Chapter 6, part 1 R. Paul Wiegand George Mason University, Department of Computer Science March 8, 2006 Outline 1 Topological

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

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

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

Frequencies, Unequal Variance Weights, and Sampling Weights: Similarities and Differences in SAS

Frequencies, Unequal Variance Weights, and Sampling Weights: Similarities and Differences in SAS ABSTRACT Paper 1938-2018 Frequencies, Unequal Variance Weights, and Sampling Weights: Similarities and Differences in SAS Robert M. Lucas, Robert M. Lucas Consulting, Fort Collins, CO, USA There is confusion

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

A Quick Tutorial on MATLAB. Zeeshan Ali

A Quick Tutorial on MATLAB. Zeeshan Ali A Quick Tutorial on MATLAB Zeeshan Ali MATLAB MATLAB is a software package for doing numerical computation. It was originally designed for solving linear algebra type problems using matrices. It's name

More information

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB MATLAB sessions: Laboratory MAT 75 Laboratory Matrix Computations and Programming in MATLAB In this laboratory session we will learn how to. Create and manipulate matrices and vectors.. Write simple programs

More information

Vector: A series of scalars contained in a column or row. Dimensions: How many rows and columns a vector or matrix has.

Vector: A series of scalars contained in a column or row. Dimensions: How many rows and columns a vector or matrix has. ASSIGNMENT 0 Introduction to Linear Algebra (Basics of vectors and matrices) Due 3:30 PM, Tuesday, October 10 th. Assignments should be submitted via e-mail to: matlabfun.ucsd@gmail.com You can also submit

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

AH Matrices.notebook November 28, 2016

AH Matrices.notebook November 28, 2016 Matrices Numbers are put into arrays to help with multiplication, division etc. A Matrix (matrices pl.) is a rectangular array of numbers arranged in rows and columns. Matrices If there are m rows and

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

Computational Photonics, Seminar 01 on Introduction into MATLAB, Page 1

Computational Photonics, Seminar 01 on Introduction into MATLAB, Page 1 Computational Photonics, Seminar 0 on Introduction into MATLAB,.04.06 Page Introduction to MATLAB Operations on scalar variables >> a=6 6 Pay attention to the response from the workspace >> b= b = >> a+b

More information

Arrays and Matrix Operations

Arrays and Matrix Operations 9 Arrays and Matrix Operations 1 THE PRIMARY MATLAB DATA STRUCTURE As we have previously stated, the basic data element in the MATLAB system is the array. A scalar is represented as a 1 * 1 array that

More information

Conditional and Unconditional Regression with No Measurement Error

Conditional and Unconditional Regression with No Measurement Error Conditional and with No Measurement Error /* reg2ways.sas */ %include 'readsenic.sas'; title2 ''; proc reg; title3 'Conditional Regression'; model infrisk = stay census; proc calis cov; /* Analyze the

More information

Computational Mathematics

Computational Mathematics Computational Mathematics Hilary Term Lecture 1: Programming Andrew Thompson Outline for Today: Schedule this term Review Introduction to programming Examples Arrays: the foundation of MATLAB Basics MATLAB

More information

CDA5530: Performance Models of Computers and Networks. Chapter 8: Using Matlab for Performance Analysis and Simulation

CDA5530: Performance Models of Computers and Networks. Chapter 8: Using Matlab for Performance Analysis and Simulation CDA5530: Performance Models of Computers and Networks Chapter 8: Using Matlab for Performance Analysis and Simulation Objective Learn a useful tool for mathematical analysis and simulation Interpreted

More information

SAS Structural Equation Modeling 1.3 for JMP

SAS Structural Equation Modeling 1.3 for JMP SAS Structural Equation Modeling 1.3 for JMP SAS Documentation The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2012. SAS Structural Equation Modeling 1.3 for JMP. Cary,

More information

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation Objective Learn a useful tool for mathematical analysis and simulation Interpreted

More information

MAT 343 Laboratory 2 Solving systems in MATLAB and simple programming

MAT 343 Laboratory 2 Solving systems in MATLAB and simple programming MAT 343 Laboratory 2 Solving systems in MATLAB and simple programming In this laboratory session we will learn how to 1. Solve linear systems with MATLAB 2. Create M-files with simple MATLAB codes Backslash

More information

Some elements for Matlab programming

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

More information

Teaching Manual Math 2131

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

More information

To add or subtract, just add or subtract the numbers in the same column and row and place answer accordingly.

To add or subtract, just add or subtract the numbers in the same column and row and place answer accordingly. Math 3 Variable Manipulation Part 2 Systems with Matrices MATRICES An alternative method to solving system of equations is using Matrices. However, before we can solve systems of equations using matrices,

More information

MATLAB INTRO 1. Suppose that we want to define a 3 1 vector x, with elements given as 3,5 and 1. We do this as follows: x = [3; 5; 1]

MATLAB INTRO 1. Suppose that we want to define a 3 1 vector x, with elements given as 3,5 and 1. We do this as follows: x = [3; 5; 1] MATLAB INTRO 1 1 MATLAB Operations Matlab uses the symbols *,/,+,-,and ˆ to denote multiplication, division, addition, subtraction and exponention, respectively. For the case of matrix multiplication,

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

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB

MAT 275 Laboratory 2 Matrix Computations and Programming in MATLAB MAT 75 Laboratory Matrix Computations and Programming in MATLAB In this laboratory session we will learn how to. Create and manipulate matrices and vectors.. Write simple programs in MATLAB NOTE: For your

More information

Mathematics 4330/5344 #1 Matlab and Numerical Approximation

Mathematics 4330/5344 #1 Matlab and Numerical Approximation David S. Gilliam Department of Mathematics Texas Tech University Lubbock, TX 79409 806 742-2566 gilliam@texas.math.ttu.edu http://texas.math.ttu.edu/~gilliam Mathematics 4330/5344 #1 Matlab and Numerical

More information

MA 162: Finite Mathematics - Sections 2.6

MA 162: Finite Mathematics - Sections 2.6 MA 162: Finite Mathematics - Sections 2.6 Fall 2014 Ray Kremer University of Kentucky September 24, 2014 Announcements: Homework 2.6 due next Tuesday at 6pm. Multiplicative Inverses If a is a non-zero

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

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

Online Technology Guide for Elementary Linear Algebra, 6e Larson/Falvo

Online Technology Guide for Elementary Linear Algebra, 6e Larson/Falvo Online Technology Guide for Elementary Linear Algebra, e Larson/Falvo Computer Software Programs and Graphing Utilities Introduction to MATLAB............................................... Introduction

More information

The EMCLUS Procedure. The EMCLUS Procedure

The EMCLUS Procedure. The EMCLUS Procedure The EMCLUS Procedure Overview Procedure Syntax PROC EMCLUS Statement VAR Statement INITCLUS Statement Output from PROC EMCLUS EXAMPLES-SECTION Example 1: Syntax for PROC FASTCLUS Example 2: Use of the

More information

CS129: Introduction to Matlab (Code)

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

More information

Program Development (SAS IML)

Program Development (SAS IML) Program Development (SAS IML) τρ 1 Review SAS IML Functions for generating matrix BLOCK Function I Function J Function REPEAT Function SHAPE Function 2 BLOCK Forms block-diagonal matrices The BLOCK function

More information

Lecture 2. Arrays. 1 Introduction

Lecture 2. Arrays. 1 Introduction 1 Introduction Lecture 2 Arrays As the name Matlab is a contraction of matrix laboratory, you would be correct in assuming that Scilab/Matlab have a particular emphasis on matrices, or more generally,

More information

Are the Folded F-test and Bartlett s equivalent?

Are the Folded F-test and Bartlett s equivalent? Are the Folded F-test and Bartlett s equivalent? I can think of two ways to solve this problem: (1) Look up what they actually are. (2) Simulate under many conditions and look closely at the results. Looking

More information

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation

CDA6530: Performance Models of Computers and Networks. Chapter 4: Using Matlab for Performance Analysis and Simulation CDA6530: Performance Models of Computers and Networks Chapter 4: Using Matlab for Performance Analysis and Simulation Objective Learn a useful tool for mathematical analysis and simulation Interpreted

More information

Convert Local Coordinate Systems to Standard Coordinate Systems

Convert Local Coordinate Systems to Standard Coordinate Systems BENTLEY SYSTEMS, INC. Convert Local Coordinate Systems to Standard Coordinate Systems Using 2D Conformal Transformation in MicroStation V8i and Bentley Map V8i Jim McCoy P.E. and Alain Robert 4/18/2012

More information

MATLAB Lecture 1. Introduction to MATLAB

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

More information

Mathematical Operations with Arrays and Matrices

Mathematical Operations with Arrays and Matrices Mathematical Operations with Arrays and Matrices Array Operators (element-by-element) (important) + Addition A+B adds B and A - Subtraction A-B subtracts B from A.* Element-wise multiplication.^ Element-wise

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

MATLAB: Quick Start Econ 837

MATLAB: Quick Start Econ 837 MATLAB: Quick Start Econ 837 Introduction MATLAB is a commercial Matrix Laboratory package which operates as an interactive programming environment. It is a programming language and a computing environment

More information

Systems of Inequalities and Linear Programming 5.7 Properties of Matrices 5.8 Matrix Inverses

Systems of Inequalities and Linear Programming 5.7 Properties of Matrices 5.8 Matrix Inverses 5 5 Systems and Matrices Systems and Matrices 5.6 Systems of Inequalities and Linear Programming 5.7 Properties of Matrices 5.8 Matrix Inverses Sections 5.6 5.8 2008 Pearson Addison-Wesley. All rights

More information

6-2 Matrix Multiplication, Inverses and Determinants

6-2 Matrix Multiplication, Inverses and Determinants Find AB and BA, if possible. 4. A = B = A = ; B = A is a 2 1 matrix and B is a 1 4 matrix. Because the number of columns of A is equal to the number of rows of B, AB exists. To find the first entry of

More information

Introduction to Matlab. CSE555 Introduction to Pattern Recognition Spring 2011 recitation

Introduction to Matlab. CSE555 Introduction to Pattern Recognition Spring 2011 recitation CSE555 Introduction to Pattern Recognition Spring 2011 recitation Matlab stands for Matrix Laboratory. It was originally designed for solving linear algebra problems using matrices. Matlab is also a programming

More information

SAS data statements and data: /*Factor A: angle Factor B: geometry Factor C: speed*/

SAS data statements and data: /*Factor A: angle Factor B: geometry Factor C: speed*/ STAT:5201 Applied Statistic II (Factorial with 3 factors as 2 3 design) Three-way ANOVA (Factorial with three factors) with replication Factor A: angle (low=0/high=1) Factor B: geometry (shape A=0/shape

More information

Introduction to MATLAB 7 for Engineers

Introduction to MATLAB 7 for Engineers PowerPoint to accompany Introduction to MATLAB 7 for Engineers William J. Palm III Chapter 2 Numeric, Cell, and Structure Arrays Copyright 2005. The McGraw-Hill Companies, Inc. Permission required for

More information

Interferogram Analysis using Active Instance-Based Learning

Interferogram Analysis using Active Instance-Based Learning Interferogram Analysis using Active Instance-Based Learning Olac Fuentes and Thamar Solorio Instituto Nacional de Astrofísica, Óptica y Electrónica Luis Enrique Erro 1 Santa María Tonantzintla, Puebla,

More information

Teachers Teaching with Technology (Scotland) Teachers Teaching with Technology. Scotland T 3. Matrices. Teachers Teaching with Technology (Scotland)

Teachers Teaching with Technology (Scotland) Teachers Teaching with Technology. Scotland T 3. Matrices. Teachers Teaching with Technology (Scotland) Teachers Teaching with Technology (Scotland) Teachers Teaching with Technology T 3 Scotland Matrices Teachers Teaching with Technology (Scotland) MATRICES Aim To demonstrate how the TI-83 can be used to

More information

CDAA No. 4 - Part Two - Multiple Regression - Initial Data Screening

CDAA No. 4 - Part Two - Multiple Regression - Initial Data Screening CDAA No. 4 - Part Two - Multiple Regression - Initial Data Screening Variables Entered/Removed b Variables Entered GPA in other high school, test, Math test, GPA, High school math GPA a Variables Removed

More information

A = [1, 6; 78, 9] Note: everything is case-sensitive, so a and A are different. One enters the above matrix as

A = [1, 6; 78, 9] Note: everything is case-sensitive, so a and A are different. One enters the above matrix as 1 Matlab Primer The purpose of these notes is a step-by-step guide to solving simple optimization and root-finding problems in Matlab To begin, the basic object in Matlab is an array; in two dimensions,

More information

CME 192: Introduction to Matlab

CME 192: Introduction to Matlab CME 192: Introduction to Matlab Matlab Basics Brett Naul January 15, 2015 Recap Using the command window interactively Variables: Assignment, Identifier rules, Workspace, command who and whos Setting the

More information

C+X. Complex Arithmetic Toolkit. Introduction

C+X. Complex Arithmetic Toolkit. Introduction C+X Introduction Complex Arithmetic Toolkit by Thomas E. Kurtz Co-inventor of BASIC This toolkit allows you to write True BASIC programs in the usual way except that certain numeric variables and arrays

More information

A Quick Introduction to MATLAB/Octave. Kenny Marino, Nupur Chatterji

A Quick Introduction to MATLAB/Octave. Kenny Marino, Nupur Chatterji A Quick Introduction to MATLAB/Octave Kenny Marino, Nupur Chatterji Basics MATLAB (and it s free cousin Octave) is an interpreted language Two basic kinds of files Scripts Functions MATLAB is optimized

More information

Introduction to MATLAB

Introduction to MATLAB Computational Photonics, Seminar 0 on Introduction into MATLAB, 3.04.08 Page Introduction to MATLAB Operations on scalar variables >> 6 6 Pay attention to the output in the command window >> b = b = >>

More information

GAUSS T U T O R I A L

GAUSS T U T O R I A L Social Science Research Lab American University Washington, D.C. http://www.american.edu/ssrl 202.885.3862 GAUSS T U T O R I A L GAUSS is a powerful matrix-oriented computer programming environment. It

More information

Position Error Reduction of Kinematic Mechanisms Using Tolerance Analysis and Cost Function

Position Error Reduction of Kinematic Mechanisms Using Tolerance Analysis and Cost Function Position Error Reduction of Kinematic Mechanisms Using Tolerance Analysis and Cost Function B.Moetakef-Imani, M.Pour Department of Mechanical Engineering, Faculty of Engineering, Ferdowsi University of

More information

Chapter 1: Number and Operations

Chapter 1: Number and Operations Chapter 1: Number and Operations 1.1 Order of operations When simplifying algebraic expressions we use the following order: 1. Perform operations within a parenthesis. 2. Evaluate exponents. 3. Multiply

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

MS in Applied Statistics: Study Guide for the Data Science concentration Comprehensive Examination. 1. MAT 456 Applied Regression Analysis

MS in Applied Statistics: Study Guide for the Data Science concentration Comprehensive Examination. 1. MAT 456 Applied Regression Analysis MS in Applied Statistics: Study Guide for the Data Science concentration Comprehensive Examination. The Part II comprehensive examination is a three-hour closed-book exam that is offered on the second

More information

Part 1. The Review of Linear Programming The Revised Simplex Method

Part 1. The Review of Linear Programming The Revised Simplex Method In the name of God Part 1. The Review of Linear Programming 1.4. Spring 2010 Instructor: Dr. Masoud Yaghini Introduction Outline in Tableau Format Comparison Between the Simplex and the Revised Simplex

More information

Basic matrix math in R

Basic matrix math in R 1 Basic matrix math in R This chapter reviews the basic matrix math operations that you will need to understand the course material and how to do these operations in R. 1.1 Creating matrices in R Create

More information

Addition/Subtraction flops. ... k k + 1, n (n k)(n k) (n k)(n + 1 k) n 1 n, n (1)(1) (1)(2)

Addition/Subtraction flops. ... k k + 1, n (n k)(n k) (n k)(n + 1 k) n 1 n, n (1)(1) (1)(2) 1 CHAPTER 10 101 The flop counts for LU decomposition can be determined in a similar fashion as was done for Gauss elimination The major difference is that the elimination is only implemented for the left-hand

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 MATLAB is a computer software commonly used in both education and industry to solve a wide range of problems. This Laboratory provides a brief

More information

Robot Mapping. Least Squares Approach to SLAM. Cyrill Stachniss

Robot Mapping. Least Squares Approach to SLAM. Cyrill Stachniss Robot Mapping Least Squares Approach to SLAM Cyrill Stachniss 1 Three Main SLAM Paradigms Kalman filter Particle filter Graphbased least squares approach to SLAM 2 Least Squares in General Approach for

More information