ENG 1181 1 College of Engineering Engineering Education Innovation Center 1 Arrays in MATLAB Topics Covered: 1.Creating arrays of numbers vectors matrices.

Slides:



Advertisements
Similar presentations
Matrices A matrix is a rectangular array of quantities (numbers, expressions or function), arranged in m rows and n columns x 3y.
Advertisements

Maths for Computer Graphics
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.
EGR 106 – Week 2 – Arrays Definition, size, and terminology Construction methods Addressing and sub-arrays Some useful functions for arrays Character arrays.
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.
Lecture 2 MATLAB fundamentals Variables, Naming Rules, Arrays (numbers, scalars, vectors, matrices), Arithmetical Operations, Defining and manipulating.
EGR 106 – Week 3 – More on Arrays Brief review of last week Additional ideas: – Special arrays – Changing an array – Some array operators – Character arrays.
Module 6 Matrices & Applications Chapter 26 Matrices and Applications I.
Matrix Mathematics in MATLAB and Excel
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Matrices The Basics Vocabulary and basic concepts.
CE 311 K - Introduction to Computer Methods Daene C. McKinney
1 Chapter 3 Matrix Algebra with MATLAB Basic matrix definitions and operations were covered in Chapter 2. We will now consider how these operations are.
1 Chapter 2 Matrices Matrices provide an orderly way of arranging values or functions to enhance the analysis of systems in a systematic manner. Their.
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 2 Systems of Linear Equations and Matrices Section 2.4 Multiplication of Matrices.
1 MATLAB 基礎. 2 MATLAB  Workspace: environment (address space) where all variables reside  After carrying out a calculation, MATLAB assigns the result.
Creating scalars, vectors, matrices Ex1 & 2. Dot Product & Cross Product Ex3. Plotting Graphs Ex4. Conversion Table Ex5. Plotting functions Finishing Ex4.
Little Linear Algebra Contents: Linear vector spaces Matrices Special Matrices Matrix & vector Norms.
MATLAB Tutorials Session I Introduction to MATLAB Rajeev Madazhy Dept of Mechanical Engineering LSU.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. A Concise Introduction to MATLAB ® William J. Palm III.
CSE123 Lecture 5 Arrays and Array Operations. Definitions Scalars: Variables that represent single numbers. Note that complex numbers are also scalars,
Two dimensional arrays in Java Computer Science 3 Gerb Objective: Use matrices in Java.
Arrays 1 Multiple values per variable. Why arrays? Can you collect one value from the user? How about two? Twenty? Two hundred? How about… I need to collect.
What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation tools. Others include Maple Mathematica MathCad.
Introduction to Matlab Module #2 Page 1 Introduction to Matlab Module #2 – Arrays Topics 1.Numeric arrays (creation, addressing, sizes) 2.Element-by-Element.
Chapter 4 Review: Manipulating Matrices Introduction to MATLAB 7 Engineering 161.
Matlab for Engineers Manipulating Matlab Matrices Chapter 4.
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
ES 240: Scientific and Engineering Computation. Chapter 2 Chapter 2: MATLAB Fundamentals Uchechukwu Ofoegbu Temple University.
ENG College of Engineering Engineering Education Innovation Center 1 Array Accessing and Strings in MATLAB Topics Covered: 1.Array addressing. 2.
Working with Arrays in MATLAB
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
>> x = [ ]; y = 2*x y = Arrays x and y are one dimensional arrays called vectors. In MATLAB all variables are arrays. They allow functions.
Chapter 2 Creating Arrays Legend: MATLAB command or syntax : Blue MATLAB command OUTPUT : LIGHT BLUE.
Lecture 20: Choosing the Right Tool for the Job. What is MATLAB? MATLAB is one of a number of commercially available, sophisticated mathematical computation.
Chun-Yuan Lin Mathematics for Computer Graphics 2015/12/15 1 CG.
Array Creation ENGR 1181 MATLAB 2. Civil engineers store seismic data in arrays to analyze plate tectonics as well as fault patterns. These sets of data.
ENG College of Engineering Engineering Education Innovation Center 1 Basic For Loops in MATLAB Programming in MATLAB / Chapter 6 Topics Covered:
Array Creation ENGR 1187 MATLAB 2. Today’s Topics  Arrays: What are they?  Vectors  Matrices  Creating Arrays.
Basics Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See
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 Engineering MATLAB – 4 Arrays Agenda Creating arrays of numbers  Vectors: 1-D Arrays  Arrays: 2-D Arrays Array Addressing Strings & String.
Introduction to MATLAB 1.Basic functions 2.Vectors, matrices, and arithmetic 3.Flow Constructs (Loops, If, etc) 4.Create M-files 5.Plotting.
BRIAN D. HAHN AND DANIEL T. VALENTINE THIRD EDITION Essential MATLAB® for Engineers and Scientists.
CMPS 1371 Introduction to Computing for Engineers VECTORS.
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
Manipulating MATLAB Vector, Matrices 1. Variables and Arrays What are variables? You name the variables (as the programmer) and assign them numerical.
An Introduction to Programming in Matlab Emily Blumenthal
1-2 What is the Matlab environment? How can you create vectors ? What does the colon : operator do? How does the use of the built-in linspace function.
Matrices. Variety of engineering problems lead to the need to solve systems of linear equations matrixcolumn vectors.
LAB 2 Vectors and Matrices Dr.Abdel Fattah FARES.
Goals for today Learn to create, combine, and index arrays Learn to multiply arrays in MATLAB Use matrix multiplication to simulate a real-world problem.
ECE 1304 Introduction to Electrical and Computer Engineering
Mathematics for Computer Graphics
Manipulating MATLAB Matrices Chapter 4
Chapter 7 Matrix Mathematics
Solving Simultaneous Equations using Matlab
Multiplying Matrices.
Vectors and Matrices I.
Chapter2 Creating Arrays
Communication and Coding Theory Lab(CS491)
Arrays and Matrices in MATLAB
Array Creation ENGR 1181 MATLAB 02.
Multiplying Matrices.
EECS Introduction to Computing for the Physical Sciences
Multiplying Matrices.
Working with Arrays in MATLAB
Presentation transcript:

ENG College of Engineering Engineering Education Innovation Center 1 Arrays in MATLAB Topics Covered: 1.Creating arrays of numbers vectors matrices Creating Arrays / Chapter 2

ENG Arrays: Vectors and Matrices The array is the fundamental form MATLAB uses to store data Scalars – one row and one column (special case) Vectors Row vector – one row and multiple columns Column vector – multiple rows and one column Matrices – multiple rows and multiple columns

ENG Arrays: Example Arrays are used in many applications.  They can represent data: An example is a position vector. The location of point P in a three dimensional space can be represented by the three Cartesian coordinates 2, 4, and 5.  Arrays of numbers can represent a vector x y z P (2, 4, 5) rArA O Year Population

ENG The year and population data in the previous slide can be entered as vectors in rows: Year = [ ] Population = [ ] Vectors or in columns:

ENG CREATING A ROW VECTOR IN MATLAB A vector can be created by typing the elements (numbers) inside square brackets [ ] separated by a comma or space(s) Type and press Enter >> pntAH = [2,4,5] pntAH = Computer Response

ENG COLUMN VECTORS >> pop = [127; 130; 136; 145; 158; 178; 211] pop = >> pntAV = [2 4 5] pntAV = Two methods: Separate elements by semicolon or “enter key”.

ENG CREATING A VECTOR WITH CONSTANT SPACING A vector in which the first term is m, the spacing is q and the last term is n can be created by typing [m : q : n]. >> x = [1 : 2 : 13] or x = 1 : 2 : 13 x = >> x = [1.5 : 0.1 : 2.1] x = If spacing (q) is omitted the default is 1 >> x = [-3 : 7] x =

ENG An alternate method Sometimes you know the number of terms and not the spacing – for this case, the function linspace is useful –Specify first term: step size: last term –linspace (first term, last term, number of terms)

ENG TWO DIMENSIONAL ARRAY - MATRIX The number of rows and columns may be the same or different Two rows and four columns (2 x 4) A (m x n), or “m by n”, matrix has m rows and n columns. (m x n) is called the size of the matrix

ENG CREATING A MATRIX IN MATLAB A Matrix is created by typing the elements (numbers) row by row inside square brackets [ ]. Two methods are shown, with and without the semicolon >> a = [ ; ; ] a = >> b = [ ] b = Type and press Enter Computer Response Type and press Enter After each row and after the ] Computer Response

ENG >> a = 7 a = 7 >> E = 3 E = 3 >> d = [5 a+E 4 E^2] d = >> g = [a a^2 13; a*E 1 a^E] g = ARRAY EXAMPLES 43

ENG THE TRANSPOSE OPERATION The transpose operation ' (single quote) For a vector: Converts a row vector to a column vector, or vice versa. For a matrix: Interchanges the rows and columns

ENG Vector transpose >> a = [3 8 1] a = >> b = a' b = >> c = 1:2:5 c = >> d = c' d = 1 3 5

ENG MATRIX TRANSPOSE Matrix example: >> c = [ ; ; ] c = >> d = c' d =