Lecture 7 Sept 19, 11 Goals: two-dimensional arrays (continued) matrix operations circuit analysis using Matlab image processing – simple examples Chapter.

Slides:



Advertisements
Similar presentations
Introduction to MATLAB The language of Technical Computing.
Advertisements

Introduction to Matlab
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
Lecture 4 Sept 8 Complete Chapter 3 exercises Chapter 4.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 12 System of Linear Equations.
Arrays-Part 1. Objectives Declare and initialize a one-dimensional array Store data in a one-dimensional array Display the contents of a one-dimensional.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 8 Arrays.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 14 Elimination Methods.
Announcements Class mailing list: send to Hyoungjune Yi: Homework at the end of class. Text is on reserve in the.
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.
Lecture 4 Sept 7 Chapter 4. Chapter 4 – arrays, collections and indexing This chapter discusses the basic calculations involving rectangular collections.
Part 3 Chapter 8 Linear Algebraic Equations and Matrices PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The.
Lecture 7: Matrix-Vector Product; Matrix of a Linear Transformation; Matrix-Matrix Product Sections 2.1, 2.2.1,
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.
1 Introduction to MATLAB MATLAB is all of the following: 1.Computational environment 2.Plotting software 3.Programming language Typical applications: 1.Calculations.
Chapter 10 Review: Matrix Algebra
COMP 116: Introduction to Scientific Programming Lecture 7: Matrices and Linear Systems.
Chapter 5. Loops are common in most programming languages Plus side: Are very fast (in other languages) & easy to understand Negative side: Require a.
Matlab tutorial course Lesson 2: Arrays and data types
Little Linear Algebra Contents: Linear vector spaces Matrices Special Matrices Matrix & vector Norms.
Barnett/Ziegler/Byleen Finite Mathematics 11e1 Review for Chapter 4 Important Terms, Symbols, Concepts 4.1. Systems of Linear Equations in Two Variables.
Copyright © 2012 Pearson Education, Inc. Chapter 8 Two Dimensional Arrays.
REVIEW 2 Exam History of Computers 1. CPU stands for _______________________. a. Counter productive units b. Central processing unit c. Copper.
Lecture 2 Using Excel OVERVIEW Complex Formulas Basic Functions Arrays Sorting Data Outlining Data Filtering Data Formatting Tables.
CSE123 Lecture 5 Arrays and Array Operations. Definitions Scalars: Variables that represent single numbers. Note that complex numbers are also scalars,
A Brief Introduction to Matlab Laila Guessous Dept. of Mechanical Engineering Oakland University.
CMPS 1371 Introduction to Computing for Engineers MATRICES.
Matrices Addition & Subtraction Scalar Multiplication & Multiplication Determinants Inverses Solving Systems – 2x2 & 3x3 Cramer’s Rule.
Lecture 28: Mathematical Insight and Engineering.
Arrays Module 6. Objectives Nature and purpose of an array Using arrays in Java programs Methods with array parameter Methods that return an array Array.
1 Lab 2 of COMP 319 Lab tutor : Shenghua ZHONG Lab 2: Sep. 28, 2011 Data and File in Matlab.
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
CHAPTER: 12. Array is a collection of variables of the same data type that are referenced by a common name. An Array of 10 Elements of type double.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Introduction MATLAB stands for MATrix LABoratory.  Basics  Matrix Manipulations  MATLAB Programming  Graphics  Image types  Image Processing  Useful.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
ES 240: Scientific and Engineering Computation. Chapter 8 Chapter 8: Linear Algebraic Equations and Matrices Uchechukwu Ofoegbu Temple University.
ME 142 Engineering Computation I Matrix Operations in Excel.
3.6 Solving Systems Using Matrices You can use a matrix to represent and solve a system of equations without writing the variables. A matrix is a rectangular.
1 EMT 101 – Engineering Programming Dr. Farzad Ismail School of Aerospace Engineering Universiti Sains Malaysia Nibong Tebal Pulau Pinang Week 10.
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
1 Lecture 3 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
LISTS and TUPLES. Topics Sequences Introduction to Lists List Slicing Finding Items in Lists with the in Operator List Methods and Useful Built-in Functions.
Chapter 8 Systems of Linear Equations in Two Variables Section 8.3.
Finishing up Chapter 5. Will this code enter the if statement? G=[30,55,10] if G
Chapter 5: Matrices and Determinants Section 5.5: Augmented Matrix Solutions.
Chapter 1 Computing Tools Variables, Scalars, and Arrays Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
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.
1 Matrix Math ©Anthony Steed Overview n To revise Vectors Matrices.
MTH108 Business Math I Lecture 20.
1-1 Logic and Syntax A computer program is a solution to a problem.
Vectors and Matrices Chapter 2 Attaway MATLAB 4E.
Programming Right from the Start with Visual Basic .NET 1/e
Matlab tutorial course
Lecture 11 Matrices and Linear Algebra with MATLAB
Communication and Coding Theory Lab(CS491)
Matlab Intro.
CSCI N317 Computation for Scientific Applications Unit R
Vectors and Matrices In MATLAB a vector can be defined as row vector or as a column vector. A vector of length n can be visualized as matrix of size 1xn.
Chapter 4 Systems of Linear Equations; Matrices
Math review - scalars, vectors, and matrices
Matlab Intro.
Presentation transcript:

Lecture 7 Sept 19, 11 Goals: two-dimensional arrays (continued) matrix operations circuit analysis using Matlab image processing – simple examples Chapter 4 exercises

Reshaping Arrays Arrays are actually stored in column order in Matlab. So internally, a 2 × 3 array is stored as a column vector: A(1,1) A(2,1) A(1,2) A(2,2) A(1,3) A(2,3) Any n × m array can be reshaped into any p × q array as long as n*m = p*q using the reshape function.

Exercise: Write a code segment in Matlab to create a 10 by 10 identity matrix.

Matrix operations Matrix addition, multiplication, inverse, determinant etc.

Matrix operations Matrix addition, multiplication, inverse, determinant, transpose etc.

Logical indexing in 2-dim matrices

Exercise: Solve a linear system of equations: 3x + 5y – 6z= 11 4x – 6y + z = 9 -2x + 3y + 5z = –13

Sum, max, min, size etc.

Example 2

4.3. Mixed Data Types Structure is a variable that can hold a group of data (of different types). Example:

Array of structures Example:

Images as arrays

Numerical representation of array (gray scale image) Visual representation

Reading and opening an image

Selecting a subimage Just like we can copy a part of an array into another array, we can copy a part of one image and create a new image.

Changing some pixel values in an image

Saving images in different formats Image formats: jpeg, bmp, png etc. >> imwrite(I, ‘king.bmp’) will save I in bmp format.

image rotation Exercise: Write a one-line statement in Matlab that will rotate an image by 180 degrees.

image rotation Exercise: Write a one-line statement in Matlab that will rotate an image by 180 degrees. >> J = I(size(I,1):-1:1, :, :);J = I(size(I,1):-1:1, :, :);

Discussions and exercises, Chapter 4 Exercise 4.1

Exercise 4.2 Write statements to do the following operations on a vector x: 1)Return the odd indexed elements.

Exercise 4.2 Write statements to do the following operations on a vector x: 2) Return the first half of x.

Exercise 4.2 Write statements to do the following operations on a vector x: 3) Return the vector in the reverse order.

Exercise 4.3 Given a vector v, and a vector k of indices, write a one or two statement code in Matlab that removes the elements of v in positions specified by k. Example: >> v = [1, 3, 5, 7, 11, 9, 19] >> k = [2, 4, 5] >> >> v ans = 1, 5, 9, 19

Exercise 4.3 Given a vector v, and a vector k of indices, write a one or two statement code in Matlab that removes the elements of v in positions specified by k.

Exercise 4.4 what does Matlab output for the following commands? 1) 6 ~= 1 : 10 2) (6 ~= 1) : 10

Exercise 4.4 what does Matlab output for the following commands? 1) 6 ~= 1 : 10 2) (6 ~= 1) : 10

Exercise 4.5. (This is quite tricky, especially without using a loop construct like while or for.) Write a statement to return the elements of a vector randomly shuffled. Hint provided is a useful one. First understand how sort function works.

Exercise 4.5. (This is quite tricky, especially without using a loop construct like while or for.) Write a statement to return the elements of a vector randomly shuffled. Hint provided is a useful one. Solution: r = rand(length(x)); [rsort, indices] = sort(x); x(indices)

Exercise 4.6. Write a statement in Matlab to perform the following operations on a vector x: return the odd indexed elements of x followed by even indexed elements of x. Exercise 4.7. x = reshape(0:2:71, 3, 12). Find the index of 52.

Summary This chapter introduced you to vectors and arrays. For each collection, you saw how to: ■ Create them by concatenation and a variety of special- purpose functions ■ Access and remove elements, rows, or columns ■ Perform mathematical and logical operations on them ■ Apply library functions, including those that summarize whole columns or rows ■ Move arbitrary selected rows and columns from one array to another ■ Reshape arrays ■ read an image, modify the array representation, view, save an image etc. ■ use Matlab to solve circuit analysis problems.