slide1
Download
Skip this Video
Download Presentation
Lecture 6 Sept 15, 09 Goals:

Loading in 2 Seconds...

play fullscreen
1 / 37

Lecture 6 Sept 15, 09 Goals: - PowerPoint PPT Presentation


  • 127 Views
  • Uploaded on

Lecture 6 Sept 15, 09 Goals: two-dimensional arrays matrix operations circuit analysis using Matlab image processing – simple examples. 4.2. Matrices Example: The following 2 x 3 matrix (matA) can be created in Matlab as follows:.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Lecture 6 Sept 15, 09 Goals:' - claudia-gay


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide1

Lecture 6 Sept 15, 09

  • Goals:
  • two-dimensional arrays
  • matrix operations
  • circuit analysis using Matlab
  • image processing – simple examples
slide2

4.2. Matrices

Example: The following 2 x 3 matrix (matA) can be created in Matlab as follows:

Dimension of a matrix can be accessed by function called size.

slide6

Matrix operations

Matrix addition, multiplication, inverse, determinant etc.

slide7

Matrix operations

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

slide10

Exercise: Solve a linear system of equations:

3x + 5y – 6z= 11

4x – 6y + z = 9

-2x + 3y + 5z = –13

slide14

4.3. Mixed Data Types

Structure is variable that can hold a group of data (of different types).

Example:

slide16

Cell arrays

A cell array is like a vector, except that each member need not be all of the same type.

slide18

Images as arrays

Numerical representation of

array (gray scale image)

Visual representation

slide20

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.

slide22

Saving images in different formats

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

image rotation

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

slide24

image rotation

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

slide25

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, :, :);

slide28

Exercise 4.2

  • Write statements to do the following operations on a vector x:
  • Return the odd indexed elements.
slide29

Exercise 4.2

Write statements to do the following operations on a vector x:

2) Return the first half of x.

slide30

Exercise 4.2

Write statements to do the following operations on a vector x:

3) Return the vector in the reverse order.

slide31

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]

>> < your code here>

>> v

ans =

1, 5, 9, 19

slide32

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.

slide33

Exercise 4.4 what does Matlab output for the following commands?

1) 6 ~= 1 : 10

2) (6 ~= 1) : 10

slide34

Exercise 4.4 what does Matlab output for the following commands?

1) 6 ~= 1 : 10

2) (6 ~= 1) : 10

slide35

Exercise 4.5. (This is a bit 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.

reshaping arrays
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.
summary
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

■ image – how to create them, open them, change etc.

ad