MATLAB Basic. Basic Data Elements The basic elements that MATLAB uses are matrices To form a matrix: Enter : A=[1 2 3 4; 5 6 7 8;9 10 11 12; 13 14 15.

Slides:



Advertisements
Similar presentations
2.3 Modeling Real World Data with Matrices
Advertisements

Numerical Solution of Linear Equations
Introduction to Matlab
Lecture 4.
Matrices A matrix is a rectangular array of quantities (numbers, expressions or function), arranged in m rows and n columns x 3y.
Maths for Computer Graphics
Solution of Simultaneous Linear Algebraic Equations: Lecture (I)
CIS 101: Computer Programming and Problem Solving Lecture 2 Usman Roshan Department of Computer Science NJIT.
General Computer Science for Engineers CISC 106 Lecture 08 Dr. John Cavazos Computer and Information Sciences 2/27/2009.
Chapter 2 Matrices Definition of a matrix.
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
Introduction to MATLAB MECH 300H Spring Starting of MATLAB.
MatlABBA. The Colon Operator (1) This is one MatLab’s most important operators 1:10 means the vector – :-7:50 –
Module 6 Matrices & Applications Chapter 26 Matrices and Applications I.
Arithmetic Operations on Matrices. 1. Definition of Matrix 2. Column, Row and Square Matrix 3. Addition and Subtraction of Matrices 4. Multiplying Row.
CE 311 K - Introduction to Computer Methods Daene C. McKinney
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.
Creating scalars, vectors, matrices Ex1 & 2. Dot Product & Cross Product Ex3. Plotting Graphs Ex4. Conversion Table Ex5. Plotting functions Finishing Ex4.
MATLAB Basics With a brief review of linear algebra by Lanyi Xu modified by D.G.E. Robertson.
Matlab tutorial course Lesson 2: Arrays and data types
Martin Ellison University of Warwick and CEPR Bank of England, December 2005 Introduction to MATLAB.
Introduction to MATLAB January 18, 2008 Steve Gu Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,
Introduction to MATLAB. Windows in MATLAB Command Window – where you enter data, run MATLAB code, and display results Command History - displays a log.
ELG 3120 Signal and System Analysis 1 Introduction to MATLAB TAs Wei Zhang Ozgur Ekici (Section A)(Section B) ELG 3120 Lab Tutorial 1.
1 Week 3: Vectors and Matrices (Part III) READING: 2.2 – 2.4 EECS Introduction to Computing for the Physical Sciences.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
1 Lab 2 of COMP 319 Lab tutor : Shenghua ZHONG Lab 2: Sep. 28, 2011 Data and File in Matlab.
Introduction to Matlab Module #2 Page 1 Introduction to Matlab Module #2 – Arrays Topics 1.Numeric arrays (creation, addressing, sizes) 2.Element-by-Element.
Scientific Computing Introduction to Matlab Programming.
Chapter 1 – Matlab Overview EGR1302. Desktop Command window Current Directory window Command History window Tabs to toggle between Current Directory &
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
Matlab Screen  Command Window  type commands  Current Directory  View folders and m-files  Workspace  View program variables  Double click on a.
MATLAB Lecture Two Tuesday 5 July Chapter 3.
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.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
LESSON 3 MATRICES Azalya Rahmatika Fathul Fithrah JURUSAN MATEMATIKA FAKULTAS MATEMATIKA DAN ILMU PENGETAHUAN ALAM UNIVERSITAS SYIAH KUALA DARUSSALAM,
Array Creation ENGR 1187 MATLAB 2. Today’s Topics  Arrays: What are they?  Vectors  Matrices  Creating Arrays.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
1 Faculty Name Prof. A. A. Saati. 2 MATLAB Fundamentals 3 1.Reading home works ( Applied Numerical Methods )  CHAPTER 2: MATLAB Fundamentals (p.24)
MATRIX A set of numbers arranged in rows and columns enclosed in round or square brackets is called a matrix. The order of a matrix gives the number of.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
CS 450: COMPUTER GRAPHICS TRANSFORMATIONS SPRING 2015 DR. MICHAEL J. REALE.
Finishing up Chapter 5. Will this code enter the if statement? G=[30,55,10] if G
CS100A, Fall 1998, Lecture 201 CS100A, Fall 1998 Lecture 20, Tuesday Nov 10 More Matlab Concepts: plotting (cont.) 2-D arrays Control structures: while,
Array and Matrix Operations EE 201 Fall  Achieve Comprehension LOL of Array and Matrix Operations. Class Learning Objectives 2.
Matrices. Variety of engineering problems lead to the need to solve systems of linear equations matrixcolumn vectors.
10.4 Matrix Algebra. 1. Matrix Notation A matrix is an array of numbers. Definition Definition: The Dimension of a matrix is m x n “m by n” where m =
A very brief introduction to Matrix (Section 2.7) Definitions Some properties Basic matrix operations Zero-One (Boolean) matrices.
2.1 Matrix Operations 2. Matrix Algebra. j -th column i -th row Diagonal entries Diagonal matrix : a square matrix whose nondiagonal entries are zero.
ENG College of Engineering Engineering Education Innovation Center 1 Arrays in MATLAB Topics Covered: 1.Creating arrays of numbers vectors matrices.
Matrices. Matrix A matrix is an ordered rectangular array of numbers. The entry in the i th row and j th column is denoted by a ij. Ex. 4 Columns 3 Rows.
LAB 2 Vectors and Matrices Dr.Abdel Fattah FARES.
13.4 Product of Two Matrices
Matrices and Matrix Operations
12-1 Organizing Data Using Matrices
ECE 1304 Introduction to Electrical and Computer Engineering
Matrix Multiplication
MATLAB DENC 2533 ECADD LAB 9.
Use of Mathematics using Technology (Maltlab)
2. Matrix Algebra 2.1 Matrix Operations.
Vectors and Matrices I.
Lecture 11 Matrices and Linear Algebra with MATLAB
Introduction to MATLAB [Vectors and Matrices] Lab 2
Section 2.4 Matrices.
Matrices Introduction.
Determinant of a Matrix
3.6 Multiply Matrices.
Matrices in MATLAB Dr. Risanuri Hidayat.
Presentation transcript:

MATLAB Basic

Basic Data Elements The basic elements that MATLAB uses are matrices To form a matrix: Enter : A=[ ; ; ; ] Show : A =

Basic Data Elements (cont.) Edit the element in the matrix: * Enter : A=[ ; ; ; ] ; A(1,3)=0 ; A Show : A =

Basic Data Elements (cont.) Generate row vectors of equally spaced : * Example 1: Enter : x=2:6 Show : x = * Example 2: Enter : x=1.2:0.2:2 Show : x =

Submatrices Create a submatrix of the matrix A entered earlier, use the : to specify the rows and columns Enter : A=[ ; ; ; ]; C=A(2:3,2:4) Show : C =

Submatrices (cont.) If the colon is used by itself for one of the arguments, either all the rows or all the columns of the matrix will be included * Enter : A=[ ; ; ; ]; A(:,2:3) Show : ans = * Enter : A=[ ; ; ; ]; A(4,:) Show : ans =

Submatrices (cont.) Generate a submatrix using nonadjacent rows or columns by using vector arguments to specify which rows and columns are to be included *Enter : A=[ ; ; ; ]; E=A([1,3],[2,4]) Show : E =

Generating Matrices Generate matrices using built-in MATLAB functions *Enter : B=rand(4) Show : B = To build triangular or diagonal matrices, we can use the MATLAB functions triu, tril and diag

Matrices Arithmetic We multiply matrix A times B by typing A*B The sum and difference of A and B are given by A+B and A-B, respectively The transpose of A is given by A’ The matrix is computed by typing A^5 * Enter : W=[1 2 ; 3 4 ]; X=W^2 Y=W.^2 Show : X = 7 10 Y =

Programming Features The line beginning with a % are comments that are not executed MATLAB has six relational operators that are used for comparisons of scalars or elementwise comparisons of arrays (1) < : less than (2)<= : less than or equal (3) > : greater than (4)>= : greater than or equal (5)==: equal (6)~= : not equal

Programming Features (cont.) 3 logical operators: (1) & : AND (2) | : OR (3) ~ : NOT Enter : A=[1 0 1 ; ; ]; B=[ ; ; ]; X=A&B Y=A|B Z=~A Show : X = Y =1 1 1 Z =

Columnwise Array Operator MATLAB has a number of functions that, when applied to either a row or column vector x, return a single number When used with a matrix argument, these functions are applied to each column vector and the results are returned as a row vector

Columnwise Array Operator (cont.) Enter : A=[ ; ; ] ; m=min(A) M=max(A) S=sum(A) product=prod(A) Show: m = M = S = product =

Graphics Plot the function on the interval [0,10] Enter : x=0:0.2:10 y=sin(x)./(x+1) plot(x,y)

Graphics (cont.) Plot the function on the interval [0,10] and compare to the graph z=sin(x) Enter : x=0:0.2:10 y=sin(x)./(x+1) z=sin(x) plot(x,y,x,z)

Help Facility Click on the help button in the toolbar or type helpbrowser in the command window Provides help on all MATLAB features Lists and describes all the MATLAB functions, operations and commands

Website ( 張智星 ) (Slides)