Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.

Slides:



Advertisements
Similar presentations
StatLab Workshop Yale University Maximiliano Appendino, Economics October 18 th, 2013.
Advertisements

Introduction to MATLAB The language of Technical Computing.
Introduction to M ATLAB Programming Ian Brooks Institute for Climate & Atmospheric Science School of Earth & Environment
Introduction to Matlab
AMS597 Spring 2011 Hao Han April 05, Introduction to MATLAB The name MATLAB stands for MATrix LABoratory. Typical uses include:  Math and computation.
Introduction to Matlab Workshop Matthew Johnson, Economics October 17, /13/20151.
Introduction to Matlab By: Dr. Maher O. EL-Ghossain.
Introduction to MATLAB
Getting started with Matlab Numerical Methods Appendix B help/techdoc/learn_matlab/learn_matlab.html.
Introduction to Matlab Οικονομίδης Δημήτρης
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
Introduction to Matlab Jianguo Wang CSSCR September 2009.
MATLAB Fundamentals.
What is MATLAB ? MATrix LABratory –Originally, it was a front-end to FORTRAN matrix routines developed in the U. of New Mexico and Stanford –Today.
MATLAB Basics With a brief review of linear algebra by Lanyi Xu modified by D.G.E. Robertson.
1 Statistical Computing in MATLAB AMS 597 Ling Leng.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
You can make this in matlab!. Matlab Introduction and Matrices.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
Introduction to Matlab 1. Outline: What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators Plotting Flow Control Using of M-File Writing.
CSE123 Lecture 5 Arrays and Array Operations. Definitions Scalars: Variables that represent single numbers. Note that complex numbers are also scalars,
1 Lab of COMP 406 Teaching Assistant: Pei-Yuan Zhou Contact: Lab 1: 12 Sep., 2014 Introduction of Matlab (I)
Introduction to MATLAB CBE 502 Mathematical Methods of Engineering Analysis.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
Yasser F. O. Mohammad Approximations and Round-off Errors.
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
MATLAB Tutorial EE 327 Signals and Systems 1. What is MATLAB? MATLAB – Matrix Laboratory The premier number-crunching software Extremely useful for signal.
Eng Ship Structures 1 Introduction to Matlab.
INTRODUCTION TO MATLAB LAB# 01
Matlab Basics Tutorial. Vectors Let's start off by creating something simple, like a vector. Enter each element of the vector (separated by a space) between.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Basics of MATLAB By DR. Wafaa Shabana
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
ES 240: Scientific and Engineering Computation. Chapter 2 Chapter 2: MATLAB Fundamentals Uchechukwu Ofoegbu Temple University.
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
Introduction to Matlab. Outline:  What is Matlab? Matlab Screen Variables, array, matrix, indexing Operators (Arithmetic, relational, logical ) Display.
Introduction to Matlab. What is Matlab? A software environment for interactive numerical computations Examples:  Matrix computations and linear algebra.
INTRODUCTION TO MATLAB MATLAB is a software package for computation in engineering, science, and applied mathemat-ics. It offers a powerful programming.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Part 1 Chapter 2 MATLAB Fundamentals PowerPoints organized by Dr. Michael R. Gustafson II, Duke University and Prof. Steve Chapra, Tufts University All.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Introduction to Matlab
Introduction to MATLAB Zongqiang Liao Research Computing Group UNC-Chapel Hill.
Introduction to Matlab Electromagnetic Theory LAB by Engr. Mian Shahzad Iqbal.
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
1 Lecture 5 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
Introduction to Matlab Engr. Mian Shahzad Iqbal LAB NO.2
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
EEE 242 Computer Tools for Electrical Engineering Lecture I Mustafa KARABULUT.
Outline What is MATLAB MATLAB desktop Variables, Vectors and Matrices Matrix operations Array operations Built-in functions: Scalar, Vector, Matrix Data.
MATLAB ……………….matrix laboratory. Bhushan D Patil PhD Research Scholar Department of Electrical Engineering Indian Institute of Technology, Bombay Powai,
Introduction to Mat lab
Statistical Computing in MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Introduction to Matlab
Matlab Workshop 9/22/2018.
StatLab Matlab Workshop
Use of Mathematics using Technology (Maltlab)
StatLab Workshop: Intro to Matlab for Data Analysis and Statistical Modeling 11/29/2018.
Introduction to MATLAB [Vectors and Matrices] Lab 2
Communication and Coding Theory Lab(CS491)
Laboratory in Oceanography: Data and Methods
CS100A Lecture 21 Previous Lecture This Lecture
Presentation transcript:

Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB

What is MATLAB? MATLAB is a tool for doing numerical computations with matrices and vectors. It is very powerful and easy to use. It integrates computation, graphics and programming in the same environment. MATLAB stands for “Matrix Laboratory”.

Matrix MATLAB works with essentially only one kind of object – a rectangular numerical matrix with possible complex entries.

Entering a matrix Matrices can be Entered manually Generated by built-in functions

An example A = [1, 2, 3; 7, 8, 9] Use ; to indicate the end of each row Use comma to separate elements of a row

Matrix operations + addition - subtraction * multiplication ^ power ‘ transpose To make * and ^ operate element-by-element, we write.* and.^

Example A= [1, 2; 3, 4] B = [0.5, 0.6; 1, 1.5] C = A*B C = A.*B

Subscripts The element in row i and column j of A is denoted by A(i, j). Example: A = zeros(2,2); A(1,1) + A(1,2) + A(2,2)

The colon operator The colon : is one of MATLAB ’s most important operators. It has many uses. 3:-2:-11 is a row vector containing integers from 3 to -11 with a increment of -2. Subscript expressions involving colons refer to portions of a matrix. A(1:3, 2) is the first to the third elements of the second column of A.

Working with matrices MATLAB provides four functions that generate basic matrices. zeros: all zeros. A = zeros(1,3) ones: all ones. A = ones(2,4) rand: uniformly distributed random numbers. A = rand(3,5) randn: normally distributed random numbers. A = randn(2,2)

Working with matrices Concatenation: join small (compatible) matrices to make bigger ones.B = [A A-2; A*2 A/4] Deleting rows and columns. B(:,2) = [ ]

Functions MATLAB provides a large range of standard elementary mathematical functions, including abs, sqrt, exp, and sin. For help on functions, type help elfun (elementary mathematical functions) help specfun (advanced mathematical functions) help elmat (advanced matrix functions) help datafun (data analysis functions)

Suppressing output If you simply type a statement and press Enter, MATLAB automatically displays the results on screen. If you end the line with a semicolon ; MATLAB performs the computation but does not display any result. Example: C = randn(5,1) C = randn(5,1);

Programming with MATLAB Files that contain code in the MATLAB language are called M-files. You create M-files using a text editor, then use them as you would any other MATLAB functions or command.

Flow Control MATLAB has many flow controls. The most basic are if statement for loops while loops

if … elseif … else … end if A > B ‘greater’ elseif A < B ‘less’ elseif A = = B ‘equal’ end

for … end for i = 1:m for j = 1:n H(i,j) = 1/(i+j) end

while … end i = 0; while (i<10000) s = s + i; i = i + 1; end

Graphics x = 0 : 0.01 : 100; y = x^2; plot(x,y) Adding plots to an existing graph: hold on Multiple plots in one figure: subplot