MATLAB Lecture Two Tuesday 5 July 2005. Chapter 3.

Slides:



Advertisements
Similar presentations
Introduction to Matlab
Advertisements

Introduction to MATLAB for Biomedical Engineering BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Lesson 2: Element-wise vs. matrix operations.
MATLAB – What is it? Computing environment / programming language Tool for manipulating matrices Many applications, you just need to get some numbers in.
MATLAB ME1107 Y Yan Reference: MATLAB for Engineers by Holly Moore (Pearson Prentice Hall)
Introduction to Matlab By: Dr. Maher O. EL-Ghossain.
MATLAB Basics CS 111 Introduction to Computing in Engineering and Science.
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
CIS 101: Computer Programming and Problem Solving Lecture 2 Usman Roshan Department of Computer Science NJIT.
Introduction to MATLAB
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
Lecture 2 MATLAB fundamentals Variables, Naming Rules, Arrays (numbers, scalars, vectors, matrices), Arithmetical Operations, Defining and manipulating.
Introduction to Matlab. Entering Commands Constants and Functions >> pi ans = >> eps ans = e-016 >> sin(pi/2) ans = 1 >> log(1000) ans =
Introduction to MATLAB
EGR 106 – Week 3 – More on Arrays Brief review of last week Additional ideas: – Special arrays – Changing an array – Some array operators – Character arrays.
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.
Sundermeyer MAR 550 Spring Laboratory in Oceanography: Data and Methods MAR550, Spring 2013 Miles A. Sundermeyer Linear Algebra & Calculus Review.
ECON 1150 Matrix Operations Special Matrices
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
Nonparametric Econometrics1 Intro to Matlab for Data Analysis and Statistical Modeling.
Introduction to MATLAB Zongqiang Liao Research Computing Group UNC-Chapel Hill.
1 M ATLAB Short Course. History of Calculator 2 3 Introduction to Matlab Matlab is short for Matrix Laboratory Matlab is also a programming language.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (2): MATLAB Environment (Chapter 1)
Introduction to MATLAB. Windows in MATLAB Command Window – where you enter data, run MATLAB code, and display results Command History - displays a log.
1 Week 3: Vectors and Matrices (Part III) READING: 2.2 – 2.4 EECS Introduction to Computing for the Physical Sciences.
CSE123 Lecture 5 Arrays and Array Operations. Definitions Scalars: Variables that represent single numbers. Note that complex numbers are also scalars,
Learner’s Guide to MATLAB® Chapter 2 : Working with Arrays.
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.
Lecture 28: Mathematical Insight and Engineering.
Introduction to Matlab Module #2 Page 1 Introduction to Matlab Module #2 – Arrays Topics 1.Numeric arrays (creation, addressing, sizes) 2.Element-by-Element.
Matlab 14.html Cost: $100 Available in labs on Windows and Unix machines.
Introduction to MATLAB. CSPP58001 MATLAB MATLAB is is a matrix-based language well suited for carrying out numerical analysis. It has many, many high-
ME6104: CAD. Module 4. ME6104: CAD. Module 4. Systems Realization Laboratory Module 4 Matlab ME 6104 – Fundamentals of Computer-Aided Design.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 18P. 1Winter Quarter Introduction to MATLAB Lecture 18.
MA/CS 375 Fall 2002 Lecture 3. Example 2 A is a matrix with 3 rows and 2 columns.
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.
Meeting 18 Matrix Operations. Matrix If A is an m x n matrix - that is, a matrix with m rows and n columns – then the scalar entry in the i th row and.
(The Transpose Operator) 1 >> C=[ ; ; ] C = >> D=C' D =
Matlab Basic. MATLAB Product Family 2 3 Entering & Quitting MATLAB To enter MATLAB double click on the MATLAB icon. To Leave MATLAB Simply type quit.
Introduction to Matlab Electromagnetic Theory LAB by Engr. Mian Shahzad Iqbal.
MA/CS 375 Fall 2003 Lecture 3. .* Multiplication We can use the.* operator to perform multiplication entry by entry of two matrices:
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.
September 15, 2005 Lecture 5 - By Paul Lin 1 CPET 190 Lecture 5 Problem Solving with MATLAB
MA/CS 375 Fall 2002 Lecture 2. Motivation for Suffering All This Math and Stuff Try the Actor demo from
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
Intro to Matlab Rogelio Long September 3, How to access MyDesktop Log in with your utep id and password.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Matlab Tutorial Iman Moazzen First Session – September 11, 2013.
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
Relational and Logical Operators EE 201 1C7-2 Spring 2012.
MTH108 Business Math I Lecture 20.
Matlab Workshop Getting Started.
Numeric, Cell and Structural Arrays One of the strenghts of MATLAB is the capabilty to handle collection of numbers called ARRAYS. MATLAB refers to scalars,
INTRODUCTION TO BASIC MATLAB
Seminar 1 for DCSP Using Matlab.
MATLAB DENC 2533 ECADD LAB 9.
Matlab Workshop 9/22/2018.
Introduction to MATLAB [Vectors and Matrices] Lab 2
Digital Image Processing
CS 175 Project in AI Discussion -- matlab
INTRODUCTION TO MATLAB
Announcements P3 due today
CS 111 Introduction to Computing in Engineering and Science
3.6 Multiply Matrices.
-seminar 1 for digital signal processing
Arrays in Matlab UC Berkeley Fall 2004, E Copyright 2005, Andy Packard
Presentation transcript:

MATLAB Lecture Two Tuesday 5 July 2005

Chapter 3

Matrices and Vectors l Input matrix A = [ 1 2 5; 3 9 0] l Use semicolon ";" to suppress output l Use … for line continuation

Matrices and Vectors l Vector is a special case of matrix l Scalar is considered 1x1 matrix g = 9.81 (no [ … ] needed) l X = [ ] creates a null matrix l Examples on page 51.

Matrices and Vectors l Matrix indexing A(i,j)ith row jth column A(m:n, k:l) specifies submatrix A(:, j) jth column A(i,:) ith row A(m:k:n,:)row m, m+k,m+2k, etc.

Matrices and Vectors l Dimension B(2,3) = 5 matrix B created large enough to have the (2,3) entry, I.e., B is 2 x 3. l The dimension is increased dynamically

Matrices and Vectors l Matrix Manipulation array as index, A([1 3 4],:) l reshape(…) function l Transpose by.’ l Hermitian conjugate by ’ l Initialization

Matrices and Vectors l Appending a row or column A = [A; u]; A = [ A u'] l Deleting a row or column A(2, :) = [ ], delete 2nd row A(:,1) = [ ], delete 1st column

Matrices and Vectors l Utility matrices eye(m,n), zeros(m,n), ones(m,n), rand(m,n), diag(A) l rot90, fliplr, flipud, tril, triu l Examples on page 56

Matrices and Vectors l Creating vectors v= initialV : increment : finalV e.g., a = 0:10:100 l linspace(a,b,n) and logspace(a,b,b) functions

Matrices and Vectors l Matrix operations + addition - subtraction * multiplication / division ^ exponentiation

Matrices and Vectors l Left division and right division A / B is A B -1 (right division) A \ B is A -1 B (left division), in particular the solution to equation Ax = b, is x = A\b.

Matrices and Vectors l Element-by-element operation.* element-wise multiply./ element-wise right division.\ element-wise left division.^ element-wise exponentiation.' nonconjugated transpose l Examples on page 60.

Relational Operations l <Less than l <=Less than or equal l ==equal l >greater than l >=greater than or equal l ~=not equal ( different from C)

Logical Operations l &logical AND l |logical OR l ~logical complement (NOT) l xorexclusive OR (a function)

Logical Functions l all, any, exist, isempty, isinf, isfinite, isnan, find

Math Functions l sin, asin, cos, acos, tan, atan, atan2, sec, cot, sinh, exp, log, log10, sqrt, abs, angle, conj, real, imag, fix, floor, ceiling, sign, etc. l Matrix functions expm(A), logm(A), sqrtm(A)

Character Strings l Strings are quoted by single quotes message = 'Leave me alone' l Strings are considered as 1xn matrix.

Eval Function l Eval interprets string as a MATLAB commend eval('x = 5*sin(pi/3)')

Lookfor l Lookfor search for key word in the function documentation l eigenvalue example

Save and Loading Data l save save entire workspace in the file matlab.mat l load load the saved file l save file.mat x y z save the values x, y, z in file.mat

Recording a Session with "diary" l diary filename Save the session to filename l diary off Turn of the diary recording

Plotting l plot(x, y) l plot(x1,y1,x2,y2) l xlabel, ylabel, title, print

Exercises l Lesson 5, exercise 3. Write a function factorial to computer factorial n! for any integer n.

Exercises l Lesson 5, exercise 5. Write a function to compute the sum of a geometric series 1 + r + r 2 + r 3 + … + r n for a given r and n.

Exercises on page 74, problem 1, 4, and 5 l Enter matrices A = [2 6; 3 9] B = [1 2; 3 4] C = [-5 5; 5 3] l Create a big matrix that has A, B, C on the diagonal

Exercises on page 74, problem 1, 4, and 5 l Delete the last row and last column l Extract the first 4x4 matrix from G l Replace G(5,5) with 4 l What do you get for G(13)? l What happens if you type G(12,1)