Matlab Intro.

Slides:



Advertisements
Similar presentations
MATLAB – A Computational Methods By Rohit Khokher Department of Computer Science, Sharda University, Greater Noida, India MATLAB – A Computational Methods.
Advertisements

Introduction to MATLAB The language of Technical Computing.
CIS 101: Computer Programming and Problem Solving Lecture 2 Usman Roshan Department of Computer Science NJIT.
Introduction to MATLAB
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 18P. 1Winter Quarter Introduction to MATLAB.
Lecture 7 Sept 19, 11 Goals: two-dimensional arrays (continued) matrix operations circuit analysis using Matlab image processing – simple examples Chapter.
Lecture 6 Sept 15, 09 Goals: two-dimensional arrays matrix operations circuit analysis using Matlab image processing – simple examples.
Concatenation MATLAB lets you construct a new vector by concatenating other vectors: – A = [B C D... X Y Z] where the individual items in the brackets.
Matlab Intro. Outline Matlab introduction Matlab elements Types Variables Matrices.
1 MATLAB 基礎. 2 MATLAB  Workspace: environment (address space) where all variables reside  After carrying out a calculation, MATLAB assigns the result.
MATLAB Basics With a brief review of linear algebra by Lanyi Xu modified by D.G.E. Robertson.
MATLAB INTRO CONTROL LAB1  The Environment  The command prompt Getting Help : e.g help sin, lookfor cos Variables Vectors, Matrices, and Linear Algebra.
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00.
Matlab Chapter 2: Array and Matrix Operations. What is a vector? In Matlab, it is a single row (horizontal) or column (vertical) of numbers or characters.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
Array Addition  Two arrays can be added if and only if both arrays have exactly the same dimensions.  Assuming the dimension requirement is satisfied,
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.
MEGN 536 – Computational Biomechanics MATLAB: Getting Started Prof. Anthony J. Petrella Computational Biomechanics Group.
Row 1 Row 2 Row 3 Row m Column 1Column 2Column 3 Column 4.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
1 Lab 2 of COMP 319 Lab tutor : Shenghua ZHONG Lab 2: Sep. 28, 2011 Data and File in Matlab.
Introduction to MATLAB Session 1 Simopekka Vänskä, THL 2010.
Introduction to MATLAB. CSPP58001 MATLAB MATLAB is is a matrix-based language well suited for carrying out numerical analysis. It has many, many high-
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 18P. 1Winter Quarter Introduction to MATLAB Lecture 18.
(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 DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
INTRODUCTION TO MATLAB Dr. Hugh Blanton ENTC 4347.
EGR 115 Introduction to Computing for Engineers MATLAB Basics 1: Variables & Arrays Wednesday 03 Sept 2014 EGR 115 Introduction to Computing for Engineers.
Array Accessing and Strings ENGR 1187 MATLAB 3. Today's Topics  Array Addressing (indexing)  Vector Addressing (indexing)  Matrix Addressing (indexing)
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
A rectangular array of numeric or algebraic quantities subject to mathematical operations. The regular formation of elements into columns and rows.
LAB 2 Vectors and Matrices Dr.Abdel Fattah FARES.
MTH108 Business Math I Lecture 20.
ECE 1304 Introduction to Electrical and Computer Engineering
Linear Algebra review (optional)
Manipulating MATLAB Matrices Chapter 4
Chapter 7 Matrix Mathematics
Microsoft Visual Basic 2005: Reloaded Second Edition
Introduction to MATLAB 7
L – Modeling and Simulating Social Systems with MATLAB
Lecture: MATLAB Chapter 1 Introduction
EGR 115 Introduction to Computing for Engineers
INTRODUCTION TO BASIC MATLAB
MATLAB DENC 2533 ECADD LAB 9.
Introduction To MATLAB
EEE 244 Numerical Methods In Electrical Engineering
7.3 Matrices.
Use of Mathematics using Technology (Maltlab)
Introduction to Matrices
Vectors and Matrices I.
Fourth Year – Software Engineering
Array and Matrix Functions
Communication and Coding Theory Lab(CS491)
Arrays and Matrices in MATLAB
Matlab Intro.
Introduction to MATLAB
Simulation And Modelling
Matlab Basic Dr. Imtiaz Hussain
Announcements P3 due today
Multi-Dimensional Arrays
Introduction to Matlab
Matlab Training Session 2: Matrix Operations and Relational Operators
Linear Algebra review (optional)
Introduction to Matlab:
Matrices in MATLAB Dr. Risanuri Hidayat.
EECS Introduction to Computing for the Physical Sciences
Working with Arrays in MATLAB
Presentation transcript:

Matlab Intro

Outline 􀁺 Matlab introduction 􀁺 Matlab elements 􀁺 Types 􀁺 Variables 􀁺 Matrices

Matlab introduction 􀁺 Matlab is a program for doing numerical computation. It was originally designed for solving linear algebra type problems using matrices. It’s name is derived from MATrix LABoratory. 􀁺 Matlab is also a programming language that currently is widely used as a platform for developing tools for Machine Learning

Matlab Matrices 􀁺 Matlab treats all variables as matrices. For our purposes a matrix can be thought of as an array, in fact, that is how it is stored. 􀁺 Vectors are special forms of matrices and contain only one row OR one column. 􀁺 Scalars are matrices with only one row AND one column

Matlab Matrices 􀁺 A matrix with only one row is called a row vector. A row vector can be created in Matlab as follows (note the commas): » rowvec = [12 , 14 , 63] rowvec = 12 14 63

Matlab Matrices 􀁺 A matrix with only one column is called a column vector. A column vector can be created in MATLAB as follows (note the semicolons): » colvec = [13 ; 45 ; -2] colvec = 13 45 -2

Matlab Matrices 􀁺 A matrix can be created in Matlab as follows (note the commas AND semicolons): » matrix = [1 , 2 , 3 ; 4 , 5 ,6 ; 7 , 8 , 9] matrix = 1 2 3 4 5 6 7 8 9

Extracting a Sub-Matrix 􀁺 A portion of a matrix can be extracted and stored in a smaller matrix by specifying the names of both matrices and the rows and columns to extract. The syntax is: sub_matrix = matrix ( r1 : r2 , c1 : c2 ) ; where r1 and r2 specify the beginning and ending rows and c1 and c2 specify the beginning and ending columns to be extracted to make the new matrix.

Matlab Matrices 􀁺 A column vector can be extracted from a matrix. As an example we create a matrix below: » matrix=[1,2,3;4,5,6;7,8,9] matrix = 1 2 3 4 5 6 7 8 9 􀁺 Here we extract column 2 of the matrix and make a column vector: » col_two=matrix( : , 2) col_two = 2 5 8

Matlab Matrices 􀁺 A row vector can be extracted from a matrix. As an example we create a matrix below: » matrix=[1,2,3;4,5,6;7,8,9] matrix = 1 2 3 4 5 6 7 8 9 􀁺 Here we extract row 2 of the matrix and make a row vector. Note that the 2:2 specifies the second row and the 1:3 specifies which columns of the row. » rowvec=matrix(2 : 2 , 1 : 3) rowvec =

Colon Operator j:k is the same as [j,j+1,...,k] is empty if j > k j:i:k is the same as [j,j+i,j+2i, ..,k] is empty if i > 0 and j > k or if i < 0 and j < k A(:,j) is the j-th column of A A(i,:) is the i-th row of A A(:,:) is the equivalent two-dimensional array. For matrices this is the same as A. A(j:k) is A(j), A(j+1),...,A(k) A(:,j:k) is A(:,j), A(:,j+1),...,A(:,k) A(:,:,k) is the k-th page of three-dimensional array A.

Matlab Matrices 􀁺 Accessing Single Elements of a Matrix A(i,j) 􀁺 Accessing Multiple Elements of a Matrix A(1,4) + A(2,4) + A(3,4) + A(4,4) 􀃎 sum(A(1:4,4)) or sum(A(:,end)) The keyword end refers to the last row or column. 􀁺 Deleting Rows and Columns to delete the second column of X, use X(:,2) = [] 􀁺 Concatenating Matrices A and B C=[A;B]

Some matrix functions in Matlab 􀁺 X = ones(r,c) % Creates matrix full with ones 􀁺 X = zeros(r,c) % Creates matrix full with zeros 􀁺 X = rand(r,c) % Creates matrix with With random numbers between (0, 1] 􀁺 [r,c] = size(A) % Return dimensions of matrix A 􀁺 + - * / % Standard operations 􀁺 .+ .- .* ./ % Wise addition, substraction,… 􀁺 v = sum(A) % Vector with sum of columns

Commands clc Clears Command window. clear Removes variables from memory. exist Checks for existence of file or variable. help Searches for a help topic. lookfor Searches help entries for a keyword. quit Stops MATLAB. who Lists current variables. whos Lists current variables (long display). ans Most recent answer. find Finds indices of nonzero elements. length Computers number of elements. max Returns largest element. min Returns smallest element. size Computes array size. sort Sorts each column. sum Sums each column.

Excersises